Return to variable scene

I am making an inventory system whereby you choose to ‘retrieve an item from your pocket’ at various points in the game. This option sends you to scene ‘pocket’. Everything currently in your inventory is listed for you to choose from.

Once the player has taken the item from their pocket (via subroutine), I want them to be able to return to the scene they were in when they chose to access their inventory (obviously the scene they are in will change so a basic goto_scene won’t work here).

I have tried to do this by setting a variable your_location at the start of every scene file and label where this option is relevant, and ending each pocket option with goto_scene {your_location}.

your_location is always named exactly after the scene name + label name.

The error I am getting is: couldn’t load scene ‘scene name label name’. The file doesn’t exist.

For clarity here is a section of code:

*comment === HELLO_WORLD ===
*label bathroom
*set your_location "hello_world bathroom"
*choice
    *if (inv_empty = false) #Retrieve an item from your pocket.
        *goto_scene pocket

*comment === POCKET ===
What should you take?
*choice
    *if (dagger = "in your pocket") #Take out the dagger.
        *set inv_item "dagger"
        *gosub_scene subroutines remove_pocket
	*goto_scene {your_location}

*comment === SUBROUTINES ===
*label remove_pocket
*set bathroom_countdown -1
*if (holding != "empty")
    You can't do that with the ${holding} in your hands.
    *set drop_trigger true
    *return
*else
    *set holding "{inv_item}"
    You have retrieved the ${holding} from your pocket.
    *return

Thoughts/ideas deeply appreciated :slight_smile:

1 Like

Use separate ref for the scene name and the label.

*temp bleh "0-Prologue-session-zero"
*temp hleb "starthere"
*goto_scene {bleh} {hleb}
3 Likes

Perfect. Thank you :+1:

You could also use a subroutine, *gosub_scene.

2 Likes

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