Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: deltamatrix on Sun 11/01/2004 12:46:49

Title: RestartGame ()
Post by: deltamatrix on Sun 11/01/2004 12:46:49
I have a situaion where one function calls a second function which calls a third function which calls a fourth function which contains a RestartGame () command.

But after that fourth and final function ends, the rest of the code within the original function continues and the game don't restart until the first function ends.

I don't want that. I want the restartgame() command to work instantly! Why doesn't it?
Title: Re:RestartGame ()
Post by: a-v-o on Sun 11/01/2004 13:03:07
There are some functions (also NewRoom, ...) which don't work instantly. You can set a variable from 0 to 1 at the RestartGame command. Then you check in the first 3 functions if this variable is 0 then execute rest of code else ignore code.
Title: Re:RestartGame ()
Post by: Scorpiorus on Sun 11/01/2004 14:55:46
Yep, the RestartGame() works exactly as RestoreGame() taking effect only when the script is finished (i.e. all the nested calls returned control).

~Cheers
Title: Re:RestartGame ()
Post by: Pumaman on Sun 11/01/2004 14:57:24
Because before a game can be restored or restarted, the text scripts all have to unwind back out to where they were originally called from - otherwise some things could really get messed up.

Sorry, that's just the way it works.
Title: Re:RestartGame ()
Post by: Alynn on Sun 11/01/2004 15:03:56
Question just for my own personal curiosity, I know RestartGame() reinits vars in the global script (I use them for my game clock and it resets the clock) but does it reset the GlobalInts for SetGlobalInt and so on (I havn't gotten to a point where I need to use them, but I will for a couple of Dialog interactions, I just wan't to know so if they don't I can change those to setting the vars in the global script).
Title: Re:RestartGame ()
Post by: Pumaman on Sun 11/01/2004 15:15:53
Yes, RestartGame resets everything. It's basically equivalent to restoring a save game which was saved at the very start of the game.