Knowing when a saved game has been reloaded

jaynabonne
16 Oct 2014, 21:08
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
16 Oct 2014, 21:14
You can overwrite the empty function inituserinterface
http://docs.textadventures.co.uk/quest/ ... rface.html

jaynabonne
16 Oct 2014, 21:46
Great! Thanks. I was hoping it was easy. :)

TextStories
17 Oct 2014, 04:53
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
17 Oct 2014, 06:31
Yes, that's normal and automatic. The output text is restored for you.

TextStories
17 Oct 2014, 06:48
Oh... is there a way to stop that?

jaynabonne
17 Oct 2014, 08:44
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
17 Oct 2014, 09:11
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
17 Oct 2014, 09:19
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
17 Oct 2014, 09:24
"inprogress" being the flag?

Thanks for this.

jaynabonne
17 Oct 2014, 09:26
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
17 Oct 2014, 13:27
Cheers, I'll give that a try.

TextStories
17 Oct 2014, 17:07
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
28 Jan 2015, 16:09
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
28 Jan 2015, 16:11
Or was I supposed to set a flag elsewhere other than just that bit of script in inituserinterface?

jaynabonne
28 Jan 2015, 17:01
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
28 Jan 2015, 17:03
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
28 Jan 2015, 17:05
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
28 Jan 2015, 17:07
I would guess it's whatever script you used to start the audio the first time. :)

Silver
28 Jan 2015, 17:07
That explains the open then shut curly braces. Duh. Cheers.