Knowing when a saved game has been reloaded

jaynabonne
This will either be easy or impossible, so...

When I save and then load the saved game, all the HTML layout changes I have made (e.g turning off the side bar, turning off the command prompt) and any JS hooking I have done are not restored. Is there a way to know when a saved game has been loaded so I can set things back the way they should be?

Pertex
You can overwrite the empty function inituserinterface
http://docs.textadventures.co.uk/quest/ ... rface.html

jaynabonne
Great! Thanks. I was hoping it was easy. :)

TextStories
When I load a saved game, the entire screen fills up with everything that had been typed/read and done last time. Is that normal?

jaynabonne
Yes, that's normal and automatic. The output text is restored for you.

TextStories
Oh... is there a way to stop that?

jaynabonne
You could probably implement the function "InitUserInterface" mentioned above and then clear the screen. :) You'd probably also have to show the room description again so that the player isn't facing a blank screen. (It does mean that from the player's point of view, save/restore don't put you back in the same state you were before. Before the save you had all the previous text to look at, whereas after a reload you don't. But that's your design decision.)

Silver
I can forsee me having problems with regards to backing audio in this regard. Need to test but I bet a reload won't remember audio playing. Is there a way to perform a check and retrigger? I think my background audio will be controlled by flags indicating various game states rather than room by room.

jaynabonne
You should be able to restart the audio in InitUserInterface. What I was thinking (even for my own game) is to set a flag the first time through on the game object. That flag will be persisted during a save and reload. When the game is reloaded, you'll see the flag set and know it's not the first time. Something like:

if (GetBoolean(game, "inprogress")) {
// game is in progress. Restart things based on current state
} else {
// first time launching game.
game.inprogress = true
}

Silver
"inprogress" being the flag?

Thanks for this.

jaynabonne
Yes. It would be "game.inprogress" (which I thought read nicely). You wouldn't need to create it up front. It would be set the first time through.

Silver
Cheers, I'll give that a try.

TextStories
jaynabonne wrote:You could probably implement the function "InitUserInterface" mentioned above and then clear the screen. :) You'd probably also have to show the room description again so that the player isn't facing a blank screen. (It does mean that from the player's point of view, save/restore don't put you back in the same state you were before. Before the save you had all the previous text to look at, whereas after a reload you don't. But that's your design decision.)


I meant specifically for me. I know when I load a TA from a different system, I do not have this program and they have less resources running in the background. I was not sure if there was a file folder some where I could note pad something to stop it before it even began.

Silver
jaynabonne wrote:You should be able to restart the audio in InitUserInterface. What I was thinking (even for my own game) is to set a flag the first time through on the game object. That flag will be persisted during a save and reload. When the game is reloaded, you'll see the flag set and know it's not the first time. Something like:

if (GetBoolean(game, "inprogress")) {
// game is in progress. Restart things based on current state
} else {
// first time launching game.
game.inprogress = true
}


I can't get this to work either. I'm not even sure I understand why it would work. All it's saying, if I understand it correctly, is have you played this before? Yes/no you haven't played this before. But there's nothing saying to the game to retrigger the audio.

Silver
Or was I supposed to set a flag elsewhere other than just that bit of script in inituserinterface?

jaynabonne
Where it says "Restart things based on current state" in the comment, that's where you'd put in your specific code to restart whatever you wish (audio in this case).

Silver
Oh hang on, I just opened the inituserinterface and bolted that bit of script on. I'm afk atm but will take another look.

Silver
jaynabonne wrote:Where it says "Restart things based on current state" in the comment, that's where you'd put in your specific code to restart whatever you wish (audio in this case).


Sorry lol right... what code does that? Or do I have to create some elaborate if script to do it? which is fine.. at least I know that's what's needed.

jaynabonne
I would guess it's whatever script you used to start the audio the first time. :)

Silver
That explains the open then shut curly braces. Duh. Cheers.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums