Wait commands and save/load

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
guo
Metal Slime
Posts: 718
Joined: Fri Dec 04, 2009 9:12 pm

Wait commands and save/load

Post by guo »

Hi, quick query. If a script has a wait command, and the player saves during the wait command, will the wait duration resume when the saved game is loaded?

Regards.
vvight.wordpress.com
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

I'm pretty sure it wouldn't. The game engine doesn't retain stuff like actively running scripts in the save data, to my knowledge.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

As Foxley said. If you want a script to continue when the game is loaded, you have to run it from your load game script. Getting it to continue from the spot which it had reached before is certainly not easy (you need to use globals and a bunch of if's or something to skip to the right point in the script). But because so many other things, like NPC locations, aren't saved either, it's unlikely that you would even want to resume a script.
User avatar
guo
Metal Slime
Posts: 718
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Well, what I want to happen is you use an item, it turns on a tag and certain NPCs appear only when that tag is on. After a wait command the tag is then turned off again, removing the NPCs. If the player were to save the game while the wait timer is running, upon loading the tag would be left on permanently (or at least until they use the item again).
Follow up questions:

*What happens to the wait command if a battle or another script (with or w/out a wait command of it's own) is initiated? Say the item that calls the script is used again?
*Would a countdown timer work better? Can the countdown timer persist between save states?

Cheers.

Edit: I forgot about "load game script". Perhaps I can just set the tag to off when a game is loaded.
Last edited by guo on Mon Jun 20, 2016 9:47 am, edited 1 time in total.
vvight.wordpress.com
User avatar
Taco Bot
Meat, Cheese, and Silicon
Posts: 484
Joined: Fri Jul 18, 2014 12:15 am
Location: Santa Cruz
Contact:

Post by Taco Bot »

guo wrote:What happens to the wait command if a battle or another script (with or w/out a wait command of it's own) is initiated? Say the item that calls the script is used again?
I'd put some sort of prevention in place to keep the item from being used twice. Reset the timer or make it check the tag before running the script.
guo wrote:Would a countdown timer work better? Can the countdown timer persist between save states?
Yes and no. What you could probably do is store the time left in a global (which, to the best of my knowledge, is saved) and read that in the load game script.

Then again, it's 3 am and I'm no expert.
Sent from my iPhone
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Timers aren't saved in save games, but globals are.

If a battle occurs, menu is entered or another script is triggered, your script will be paused until they finish. While paused, wait commands don't continue to count down. So if a script is triggered that contains no waits or implicit waits, then it's not really paused at all. Running the same script twice at once is indeed something you usually want to avoid, although in this case it wouldn't lead to any bad behaviour.

Turning the tag off in the load game script would certainly be the easiest solution. If you wanted the correct delay before turning it off you would have to use globals to store that information.
User avatar
guo
Metal Slime
Posts: 718
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks, I think I'll just go with the load game script, and a check tag at the start of the script itself to prevent double triggering!
vvight.wordpress.com
Post Reply