Gosub_scene Question

Not sure if anyone will be able to answer this, but I currently have combat setup in its own scene.
To start combat, I set a few variables then start combat like this:

*gosub_scene db_enemies veteran_guard
*gosub_scene combat combat_start

This works fine, and eventually when combat ends, I set a few variables like “combat_result” and call *return which takes me back to the original place where I called *gosub_scene.
No issues in testing, however I got thinking about compiled games and realized that the subroutine stack probably doesn’t get saved, so if someone closed the game within combat, it would likely break.
Does anyone know if that is actually the case?
Will the stack get saved and continue to function, or should I use a different method to enter and exit combat?
Using *gosub_scene is certainly the simplest way, but I could also save the scene and label before combat, then use *goto_scene to enter and exit. (But temps are lost)
It’s probably also possible to use the new checkpoint system to hack something together, but I would prefer to avoid wasting it like that. (Since using it this way would prevent me from using it the intended way)

Quote:
*gosub_scene, however, essentially (if briefly) loads the indicated file behind-the-scenes and does not actually “unload” the current scene file in the process, meaning that unlike for a *goto_scene, all of the current scene’s *temp variables and #option _reuse states are retained in memory and will still apply after the subroutine has been used.

I doesn’t say specifically, but I would guess it is all saved if you close the game. Otherwise, a lot of the games would have that problem already, and no one’s complaining, so I would bet it isn’t a problem.

1 Like

After I saw your message, I decided to test it and you were correct.
I compiled my game, then went into combat, took a couple turns, then refreshed.
When I looked at the cache, the scene stack is saved under “choice_subscene_stack”.

    "sceneName": "combat",
    "choice_saved_checkpoint_start": true,
    "choice_subscene_stack": [
      {
        "name": "town",
        "lineNum": 235,
        "indent": 8,
        "temps": {
          "choice_reuse": "allow",
          "choice_user_restored": false,
          "_choiceEnds": {
            "164": 177,
            "166": 177,
            "168": 177,
            "170": 177,
            "172": 177,
            "174": 177,
            "176": 177,
            "232": 321,
            "249": 321,
            "266": 321,
            "284": 321,
            "302": 321,
            "320": 321,
            "1479": 1499,
            "1482": 1499,
            "1485": 1499,
            "1488": 1499,
            "1491": 1499,
            "1494": 1499,
            "1497": 1499
          },
          "_looplimit": 1000,
          "param": [],
          "choice_crc": -1068170941,
          "town_location": "3"
        }
      }
    ]

There’s also a “choice_substack” which I assume is for the current scene.

Also of note, despite what the wiki says, I needed to include all scenes in the *scene_list for it to load properly in the compiled version. Otherwise I got an error message as soon as I tried to use *goto_scene or *gosub_scene to any scene that wasn’t included.

1 Like

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