So, I’m working on a game. When I ran it via browser, it was jumping unexpectedly after a choice to the end of the game (the page with restart button, etc.)
I downloaded CSIDE and put my code into it. I ran it and saw the same problem. I then stepped through it and saw that no matter which #choice I picked, it jumped to the end page when I reached the *finish statement for that choice. I never get to the “I should see this text” line. Here is my code (note, there is a *create gender “none” statement in the setup file):
*comment set gender
*set gender "male"
*set gender "female"
#Hello, my child (use "they" pronouns)
*set gender "nonbinary"
I should see this text
No wonder! The purpose of the *finish command is to move the game to the next scene, so if there is none, it’ll just end the game. What you’re looking for instead is a *goto. Place a *label before the “I should see this text” line and then have your choices end in *goto [label name]. Or, if all the options are meant to lead to the same place, just use a *fake_choice instead.
So, each choice that doesn’t move to a new scene or jump around should have a goto to a label immediately following the choice statement? I thought *finish meant “*finish the choice”. The example in the tutorial is not clear about that. Thanks!
That’s right (except, apparently, for the last choice option, you can skip the goto for that one?). See this example by the Choicescript devs:
#Be very naughty.
Santa refuses to give you a present.
#Be mostly nice.
Santa gives you a present reluctantly.
#Be as nice as can be.
Santa gives you a present enthusiastically.
Inside the gift box is a video game!
That example, incidentally, is from a page on implicit control flow. If you activate it, you can skip the label and the goto for every choice option that doesn’t jump around or finish.