Do *goto_scene commands override an existing gosub_scene, preventing the next called *return* from executing?

Hi all!

Running a build of my WIP on the CogDemos.ink. I have it setup for when you go to the inventory from the housing, it executes the inventory file as a gosub_scene. Then when going to weapons from inventory, that uses a goto_scene. When I executed the *return function from that goto_scene file, it said that there wasn’t an area to *return to.

Tried to research this one, couldn’t find a prior thread, so opening this one!

IIRC, yes, every new gosub overwrites where the game tries to return to.

From what I understand, though, you want to have multiple inventory systems, that can be done with a ‘page’ variable or just with a navigation menu

EDIT:
For example, this is all in the choicescript_stats file

*label main
Stuff for the main stats page

*goto navigation_menu
*label page2
Stuff for this page

*goto navigation_menu
*label page3
Stuff for this page

*goto navigation_menu

*label page4
Stuff for this page

*goto navigation_menu

*label navigation_menu
*choice
 #Main Page
  *goto main
 #Page 2 Title
  *goto page2
 #Page 3 Title
  *goto page3
 #Page 4 Title
  *goto page4
2 Likes

I would have expected this to work. That said, I would strongly advise you try not to sprinkle normal goto_scenes amidst gosub_scenes. That could lead to some very complicated and hard to follow systems. Is there any particular reason you can’t just make it another gosub_scene? Two returns should get you the same result?

Edit:

I can’t remember the specific implementation details but there is to my knowledge a return “stack” so you can nest gosub routines (both across files and within). There might be instances where that stack is cleared or behaviour isn’t quite as one might expect, but by and large I wouldn’t expect this statement here to be true.

5 Likes

IIRC, you can stack gosubs, even gosub_scenes, but once you goto_scene it clears the stack. @CJW’s solution is the correct one, use another gosub_scene and two returns.

1 Like

I appreciate you all! I was worried that it wouldn’t have a nested stack and as a result would cause a lot of issues.

Will fix that with correct logic. Thanks!

I had the same problem around 10 minutes ago, so this thread kind of scared me :sweat_smile:

Either way, good to know.

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.