Unsure how to use *choice

I’m having trouble with the *choice feature. So, I used it and tried to make it work, but it just keeps giving me an error message.

The error I’m getting is: startup line 25: invalid indent, expected at least one ‘choice’

My code looks like this:

*choice
#Explore and discover this strange thing.. I'm not scared!
You peek outside by, to your confusion, nothing is wrong; instead, the world has turned white
with something that you don't yet understand; snow. Now that you've established that everything
is safe, you retreat to the den.
*finish
#That seems scary.. I'll just stay in the lair.
It's warm inside the lair. You stretch and curl up to sleep.
*finish

Indents are important in ChoiceScript, your code should look like this:

*choice
    #Explore and discover this strange thing.. I'm not scared!
        You peek outside by, to your confusion, nothing is wrong; instead, the world has turned white with something that you don't yet understand; snow. Now that you've established that everything is safe, you retreat to the den.
        *finish
    #That seems scary.. I'll just stay in the lair.
        It's warm inside the lair. You stretch and curl up to sleep.
        *finish
2 Likes

Ok, I’ll try~ Thanks for the advice!
It worked, thanks!!
Ok, so, I’m really sorry but… now I’m struggling with something else. >.<

I have a code like this:

*choice
    #Male
        Ok.
        *set gender male
        *page_break
    #Female
        Ok.
        *set gender female
        *page_break

But it says that " It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block." when I try to use this script…
Any help?

After using *choices and *ifs you have to finish with a *goto, so that the code knows where to go after it reaches that point.

The *gotos go to *label of a name you can define.

*choice
    #Male
        Ok.
        *set gender male
        *page_break
        *goto afterGender
    #Female
        Ok.
        *set gender female
        *page_break
        *goto afterGender

*label afterGender

Continue your game here...

Alternatively you can use *fake_choice, which doesn’t require a *goto at the end, and it will simply continue down when it finishes the choice code.

Also use this program to make coding easier, as well as handling indenting.

1 Like

Thank you! You’re all so helpful.
I was confused since my previous code didn’t want it, I don’t think…
Thanks soooo much!!!

Oh. Hey. GUESS WHO’S HAVING PROBLEMS AGAIN >.<
My script looks like this:

*choice
    #Claim the kingdom!
        You grin. "I'll go for the kingdom!"
        *goto KingdomClaim
    #Claim more small villages.
        You take to the air. "Starting small is a good idea."
        *goto Town2Claim

And the error message is:

"It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block."

And there is a *label for both of the *goto’s…

Is the line number on your error message the same as the choice you posted?
Maybe it’s getting caught up somewhere else?

Was about to say that. Always look at the line number it mentions first. (Someone it’ll be elsewhere but more likely that’s where the problem is and you can work the problem out more easily.)

2 Likes

You must missed this one #choice, hidden below the pile of hay.

Try to look for it.


And btw, if you encountered multiple problems, try to ask them in a single thread instead. You know, keep things tidy.

1 Like

Ok, so someone already gave me a solution to this, it didn’t seem to work!!

Code:

*choice
    #Male
        Ok.
        *set gender male
        *page_break
        *goto afterGender
    #Female
        Ok.
        *set gender female
        *page_break
        *goto afterGender

*label afterGender

Error message:

"It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block."

It should work like that, i cant see any problems. Also you don’t need to use *page_break after a choice as it does that automatically. Hope someone can help with that :slight_smile:

1 Like

Actually wondering if removing the *page_break will fix your problem for you! Give us an update when you can! :slight_smile:

2 Likes

Also, if your gender variable is a string variable, it wont recognise *set gender male . male should be “male” .

*choice
    #Male
        *set gender "male"
        *goto scene
    #female
        *set gender "female"
        *goto scene
    
*label scene

This should work. But the one you posted shouldn’t have been giving that error but non-existent variable error. So im not sure whats the problem there…

Also dont forget to create your variable first :slight_smile:

It’s probably that.
So maybe “male” an “female”. Assuming the startup variables are already made.
Edit: Nevermind, read the error message and it has nothing to do with that. I can only blame page_break.
Edit 2x: I tried creating variants of what you did, nope, no error messages at all. You might want to show us your startup variables.

1 Like

Yeah, page_break isn’t necessary, but inserting one before *goto has no effect at all and thus shouldn’t have any errors either.

1 Like

Ok, here’s my startup thingy:

*title [here]
*author [here]
*create strength "20"
*create stamina "20"
*create speed "20"
*create gender "0"
*create name "0"

*scene_list
  startup

Did removing *page_break help?
If not:

  1. Put the scenelist before the creates (iirc this might not be the source of the prob but might cause trouble down the line)
  2. Remove 0 from the create for gender. “” will do iirc.
  3. Check the indents
1 Like

Ok guys. I’m very new, so forgive me, but I’ve just discovered I was being an idiot.
The script BEFORE the gender was the one being wrong, NOT the gender script. Oh golly. I don’t know how I did that. Sorry guys~
:heart:

1 Like

Don’t worry.
Did you manage to fix the problem?

Also, on a note before, cause i think no one corrected that:
If you have flavor-text (like the ok) a page_break is okay.
In fact:
If you have flavor-text, a page_break might help with the flow of the story if the text is not part of the narrative as such.
Otherwise it’ll appear above the next text body

1 Like

Yes, I did fix the problem!
And thanks for the advice.