Game throwing up an error about a number due to an *if?

So, I’m running into an error that says:
‘unit line 1388: expected a #option here, not a *goto’
For reference, the bit of code it’s having trouble with is this:

	*if  (t_belief) =true
		*hide_reuse #"${t_name} fix?"
		*goto no_fix

I’m not sure what I’m missing. As such, would someone be able to point it out for me?
Anyway, I hope that you who are reading this have a good rest of your day.

1 Like

Looks like it’s getting confused by the indent after hide_reuse. Basically it’s expecting to see #"${t_name} fix?" on the line immediately after the *choice. I remember having trouble sometimes with this kind of thing, too!


	*if  (t_belief) =true *hide_reuse #"${t_name} fix?"
		*goto no_fix

(similar example here if that’s helpful)

1 Like

Indents for choice blocks are tricky when you’re getting started.

You’ll generally have three indent levels:

    #option (mb w *hide_reuse/other inline command)
        Stuff after option (eg text, *set, *goto)

but sometimes four, if one or more option only appears *if some variable is right:

    *if (conditions_on_option = "satisfied")
             Stuff after option (text, *set, *goto)

It’s possible to do the *if as an inline command at the same indent level as the #option it refers to, as Stewart suggested. Personally I find it easier to parse it when I give it its own line/indent level, especially if (a) I’m using other inline commands like *hide_reuse or *selectable_if, or (b) there’s a whole bunch of variables behind the *if:

    *if ((straight and cis) and (white and male)) and middle_class
        *selectable_if neurotypical #option
             Stuff after option

The problem with your original snippet is that the #option and the “Stuff after option” (in this case just a goto) are indented to the same level.

That’s a problem because as long as there’s any possibility that your *choice block is continuing, the computer will try to understand and display everything you put at that indent level as an #option.

That’s what that error message is telling you: “you’re telling me with the indents that this line is an #option, but it starts with *goto, not #”.

Edit: as an aside,

*if  (t_belief) =true

doesn’t need the parentheses… it’ll work just fine either as *if t_belief = true or just *if t_belief. If you want to use it as an inline command, putting parentheses like this *if (t_belief = true) will make it more likely to be parsed correctly.


Should be:

	*if (t_belief = true)
		*hide_reuse # "${t_name} fix?"
			*goto no_fix

Broken down:

INDENT ZERO: Let the computer know that you are setting a range of choices to pick from.


INDENT ONE: Set aside certain choices only if a variable is true. Make sure that you don’t cut your expression in half – enclose it all in brackets to be sure. This way you can adapt it to be more complex if you need it to be; good habit to get into. You’ll also put most of your choices into INDENT ONE because it’s directly under the *choice command; an exception is made here for the *if statement.

1	*if (t_belief = true)
1	# Another choice
1	# Yet another choice

INDENT TWO: You want to link a choice to the *if statement, so it’s the next indent and underneath it. You got the *hide_reuse command right, especially combining it with an *if statement for a more complex set of requirements to have it show up. Personally, I prefer *disable_reuse so the reader can remember what they’ve already selected previously, but that’s just a preference.

1	2	*hide_reuse # "${t_name} fix?"

INDENT THREE: You want to link the choice body to the selected choice, so it’s the next indent and underneath it.

1	2	3	*goto no_fix

Alright, I did what you suggested, my final product is below, however, it is still giving me the same error at the same choice.

	*if (t_belief =true)
	*hide_reuse#"${t_name} fix?"
			*goto no_fix
	*elseif (l_belief =true)
	*hide_reuse#"${l_name} fix?"
		*goto no_fix
	*elseif (n_belief =true)
	*hide_reuse#"you fix?"
		*goto n_ask_fix
	*elseif (d_belief =true)
	*hide_reuse#"${d_name} fix?"
		*goto no_fix

The other 3 choices below the first one are unchanged because I wanted to test if my changes worked on the first choice before altering the others, however, that doesn’t seem to be the case.
As far as I can tell, the indentations are correct now, so why is it still giving me the error?

Does this work?

(Basically, you need to indent a level after an *if or *elseif, and then the result of an #option needs to be indented a level. You might also need to add a space between the *hide_reuse and the #option but I’m not sure)

@Havenstone and @will talked a bit about indenting above, but there’s also a page on the choicescript wiki that goes into more detail.

Separately, you might want to make sure there’s always some option here that will be true so the player always goes somewhere. Alternatively, add a fallback *else statement at the very end–otherwise you might end up redirecting them somewhere unexpected.


That seems to have fixed it. Thanks, smiley.
Looks like I need to do more logic-based courses, grin.
Anyway, I hope you all have a good rest of your day!

1 Like

Who’s grin?

And your issue in all cases was indenting. Pay special attention to your indents and look at how other games do it.

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