Total Newbie Help - "Illegal to Fall Out of Choice Statement"

Hi all, and thank you in advance for your help!

I am in the process of just beginning to teach myself how to use ChoiceScript, and I keep running into an error with my code even thought I am following along with a guide that give explicit directions on what you need to type to learn the basics. I’ve browsed the topics that are related to my problem here, but with my limited knowledge at this phase I am having a bit of a hard time deciphering what exactly I’ll need to do to correct my issue.

My code is as follows:

*title Game's Title
*author Alexandra

*scene_list 
	startup
	foo

*create gender "undetermined"
*create mx "mx"

What is your gender?
*choice
	#Male
		*set gender "male"
	#Female
		*set gender "female"
*label gender_chosen
*if (gender = "male")
	*set mx "mr"
*if (gender = "female")
	*set mx "ms"
We'll use ${gender} pronouns for you. 
*line_break
We'll use the title $!{mx}.

*ending

When I test it in Firefox and select “female” as my gender, it works just fine. But when I select “male” as my gender, I get the error: “startup line 15: It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block”

I understand the basic concepts behind *goto and *finish, which end the current scene, but I do not understand why I’d need to insert them here or why female will work but male won’t.

Basically, I’m new and just totally lost.

Thank you so much for all your assistance!

On line 15 you have to check the spacing. If indentation is off by even 1 it will crash the game. If you are new to coding and want to delve into writing I’d suggest using one of the Choice script program.

There are tutorials for it as well. I was struggling a few months ago to wrap my head around this stuff and this program made me make leaps and bounds.

Thank you, I will definitely give that program a shot! This is definitely not the easiest thing to grasp and I’ll need all the help I can get.

With that said, insofar as the spacing issue, I’ve been using indents, not 4 spaces which apparently was my other option. Because of that, the indentation is not off - it is identically tabbed to my #Male choice above.

For the sake of further testing this, I added another choice below this one:

*choice
	#Okay, that sounds good.
		Great!
	#No, that's wrong.
		Wait what?

And I get the same issue with my first choice (Okay, that sounds good) but not the second one (No, that’s wrong), just as I do above, but the indentation is also identically aligned.

Or, I apologize, did I misunderstand what you meant by check the spacing?

@Alexandra_VanDerlofs Why not use a *fake_choice instead of a *choice? It seems you’re just going to state the same result and inform the reader/player of their chosen gender. Also, your choice needs to have a *goto at the end of a choice to make it go somewhere while using the *fake_choice you won’t need the *goto

If you’re using a *choice command the format is like this

*choice
#Option one
	*set blah blah
	*goto nextpage
#Option two
	*got nextpage

You can code your first post like this and use *fake_choice rather than a *choice if you plan to have the same result anyway.

*title Game's Title
*author Alexandra

*scene_list 
	startup
	foo

*create gender "undetermined"
*create mx "mx"

What is your gender?
*fake_choice
	#Male
		*set gender "male"
		*set mx "mr"
	#Female
		*set gender "female"
		*set mx "ms"

We'll use ${gender} pronouns for you.
We'll use the title $!{mx}.

*ending

This link here is really good if you’re having a little bit trouble with the codes, have fun learning choicescript :grin:

1 Like

Typically, when I got that error it meant my spacing is off on the indentation of my # code or didn’t have a proper goto command in place.

Honestly, I’d copy and paste this code from the original download and work backward.
What kind of animal will you be?
*choice
#Lion
*goto claws
#Tiger
*label claws
In that case, you’ll have powerful claws and a mighty roar!
*finish
#Elephant
Well, elephants are interesting animals, too.
*finish

Once I started using chronicler I’ve hardly ever encountered this problem.

I’m on my phone so I’m not sure if that code formats right.

Thanks for posting that master list. I couldn’t find it earlier.

1 Like

Thank you SO MUCH! That was incredibly helpful. I don’t think I fully understand the difference between fake choices and choices yet, so I’ll read up on it.

2 Likes

@Tool No problem, I actually pinned it so whenever I get lost I just click on it.

@Alexandra_VanDerlofs Its okay just try and try until you get the code right. The master list link I gave will really help. Have fun :grin:

1 Like

@Tool and @M-D-M thank you both again, you’ve given me the resources to really get started! Hope you both have a great day!

2 Likes

Sorry if this has already been solved, but the issue is exactly what is stated in the error message: “It is illegal to fall out of a *choice statement; you must *goto or *finish before the end of the indented block”

The fix is to add a goto statement in each choice:

...
What is your gender?
*choice
	#Male
		*set gender "male"
		*goto gender_chosen
	#Female
		*set gender "female"
		*goto gender_chosen

*label gender_chosen
...

Or as @M-D-M stated you can use a *fake_choice

2 Likes

I’ve been stuck in jury duty selection all day so I’m glad I could be of help lol.

3 Likes