Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Game hesitates when reloading game.script (Game restart)  (Read 3919 times)

0 Members and 1 Guest are viewing this topic.

rkitting

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 44
    • View Profile
Game hesitates when reloading game.script (Game restart)
« on: August 23, 2008, 12:49:34 AM »

Hello,

I'm using Game.Reset() to restart my game, but also detaching and attaching the game.script in the first scene (menu). This all works fine, but the mouse freezes for 2 seconds while game.script is being loaded again.
Is there a better way to restart a game or some hidden function not mentioned in the docs?
Thx a lot.

P.S. for those of you in Germany, come check out our game demo at the Games Convention in Leipzig! Halle 2, HTWK-Stand
www.palladion-adventure.com
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Game hesitates when reloading game.script (Game restart)
« Reply #1 on: August 23, 2008, 07:56:25 AM »

So that's you! We were talking about your game yesterday in the channel! ;)  ::beer ::beer

I'm not sure why you want to detach your game.script. I myself used for example in Ghost in the Sheet the following logic. I've a global variable called GameInit which is an object initialized in the game.script. This object has 2 methods (Init for setting all variables and Done for releasing occupied global memory resources.

Code: WME Script
  1. #include "scripts/base.inc"
  2.  
  3. method Done() //abbreviated version
  4. {
  5.                 global WinMenu;
  6.                 Game.UnloadObject(WinMenu);
  7.                 Game.DeleteWindow(KostWindow);
  8.                 Game.DeleteWindow(SkipWindow);
  9.                
  10.                 Game.DeleteWindow(EavesWindow);
  11.                 Game.UnloadObject(EavesObject);
  12.                 Game.UnloadObject(Sounder);
  13.                 Game.UnloadObject(teleObject);
  14.                 Game.UnloadObject(lanovkaPuzzle);
  15.                
  16.                 Game.DeleteEntity(FluentSound1);
  17.                 Game.DeleteEntity(FluentSound2);
  18.                 Game.DeleteEntity(FluentSound3);
  19.                
  20.                 Game.UnloadObject(talkRobot);
  21. }
  22.  
  23. method Init()
  24. {
  25.                 Keyboard = Game.Keyboard;
  26.                 Scene = Game.Scene;
  27.                
  28.                 // Load the window for Bone
  29.                 KostWindow = Game.LoadWindow("windows\kost.window");
  30.                
  31.                 // Load the window for Skipping cutscenes
  32.                 SkipWindow = Game.LoadWindow("windows\skip.window");
  33.                 SkipWindow.Visible = false;
  34.                
  35.                 ElektrikaPuzzle = new Object("SklepElektrika\scr\elektrika.script");
  36.                 ElektrikaPuzzle.Initialize();
  37.                
  38.                 PlynObject = new Object("HalaB_GasPanel\scr\plynObject.script");
  39.                
  40.                 var win = Game.LoadWindow("interface\system\caption.window");
  41.                 global WinCaption = win.GetWidget("caption");
  42.                
  43.                 FluentSound1 = Game.CreateEntity();
  44.                 FluentSound2 = Game.CreateEntity();
  45.                 FluentSound3 = Game.CreateEntity();
  46.                
  47.                 talkRobot = new Object("scripts\talkRobot.script");
  48.                
  49.                 Game.RemoveWaitCursor();
  50.  //               etc... etc... abbreviated for simplicity
  51. }
  52.  
  53.  

Now on my restart I call it like this:

Code: WME Script
  1.         global GameInit;
  2.         GameInit.done();
  3.         Game.Reset();
  4.         GameInit.Init();
  5.  
  6.         Game.ChangeScene("scenes\Intro\Intro.scene");   
  7.  

No delays or nothing.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Game hesitates when reloading game.script (Game restart)
« Reply #2 on: August 23, 2008, 09:26:02 AM »

Loading the script should not freeze the game. It depends on what the script is actually doing when it's executed.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

rkitting

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 44
    • View Profile
Re: Game hesitates when reloading game.script (Game restart)
« Reply #3 on: August 23, 2008, 07:32:12 PM »

Thanks a lot! This really helped. I call GameInit.Done() and Game.Reset() from the menu button when I want to restart.
Next problem is when I use it while the actor is talking. I call actor.StopTalking(), and it returns successful, but you can still hear him talking.

Do I have to somehow unload the character (which game_loop.script does not like)?
Logged
 

Page created in 0.092 seconds with 24 queries.