Will gosub save previous state?

Discuss authoring naninovel scenario scripts.
Post Reply
gradstein
Posts: 22
Joined: 09 Sep 2020 19:03

Will gosub save previous state?

Post 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.

idaot
support
Posts: 262
Joined: 01 Aug 2020 08:25

Re: Will gosub save previous state?

Post 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.

gradstein
Posts: 22
Joined: 09 Sep 2020 19:03

Re: Will gosub save previous state?

Post 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

idaot
support
Posts: 262
Joined: 01 Aug 2020 08:25

Re: Will gosub save previous state?

Post 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.

Post Reply