Will gosub save previous state?

Posted: 25 Aug 2022 16:48
by gradstein

If I have a bunch of characters in a scene on one bg, and then use a gosub that changes the bg and characters for a quick moment, will it return to the previous scene and staging from where it left off? Is that whole state saved in memory to return to exactly where I left off? Otherwise it is quite tedious to restore the scene with many staged characters when they’ve all moved and changed animations since the initial staging at top of scene so I’d have to cherry pick each line of code.


Re: Will gosub save previous state?

Posted: 26 Aug 2022 09:55
by idaot

Game state is saved at pretty much every line. @gosub returns to the spot it's called when it's finished executing, not the start of the script, and it remembers that even when saved in the middle of it.


Re: Will gosub save previous state?

Posted: 01 Sep 2022 19:08
by gradstein

Sorry, not clear.

If i have a scene staged with five characters on a background, then i have a gosub that's a new background and one of those five characters doing something else, when that gosub ends, does it restore the previous background and the position of all the characters that were in that scene? or is it essentially just inserting a block of code into that moment and if i don't "restage" the scene after the gosub, ill be in a weird visual state


Re: Will gosub save previous state?

Posted: 01 Sep 2022 19:33
by idaot

"when that gosub ends, does it restore the previous background and the position of all the characters that were in that scene?"

No. @gosub is a way to reuse code and it doesn't have a temporary state or anything too complex that you're thinking of. A "@char Kohaku" command will override any previous "@char Kohaku" commands, regardless if it's contained within a @gosub or not.