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

**URL:** <https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310>\
**Category:** ChoiceScript Help\
**Created:** [November 25, 2023, 12:04am UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310 "2023-11-25T00:04:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArchivistAlpha096](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/archivistalpha096/32/203655_2.png) [@ArchivistAlpha096](https://forum.choiceofgames.com/u/ArchivistAlpha096)\
**Post date:** [November 25, 2023, 12:04am UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/1 "2023-11-25T00:04:13Z")

</div>

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:

```choicescript
*choice
	*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.

---

<div class="post-metadata">

**Author:** ![Stewart\_Baker](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stewart_baker/32/184264_2.png) [@Stewart\_Baker](https://forum.choiceofgames.com/u/Stewart_Baker)\
**Post date:** [November 25, 2023, 12:07am UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/2 "2023-11-25T00:07:47Z")

</div>

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!

Try:

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

```

([similar example here if that’s helpful](https://forum.choiceofgames.com/t/using-hide-reuse-and-if/113523))

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [November 25, 2023, 3:25am UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/3 "2023-11-25T03:25:25Z")

</div>

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

You’ll generally have three indent levels:

```choicescript
*choice
    #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:

```choicescript
*choice
    *if (conditions_on_option = "satisfied")
        #option
             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:

```choicescript
 *choice
    *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,

```choicescript
*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.

---

<div class="post-metadata">

**Author:** ![will](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/will/32/132033_2.png) [@will](https://forum.choiceofgames.com/u/will)\
**Post date:** [November 25, 2023, 3:43am UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/4 "2023-11-25T03:43:30Z")

</div>

Should be:

```choicescript
*choice
	*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.

```choicescript
*choice

```

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.

```choicescript
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.

```choicescript
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.

```choicescript
1	2	3	*goto no_fix

```

---

<div class="post-metadata">

**Author:** ![ArchivistAlpha096](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/archivistalpha096/32/203655_2.png) [@ArchivistAlpha096](https://forum.choiceofgames.com/u/ArchivistAlpha096)\
**Post date:** [November 25, 2023, 5:36pm UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/5 "2023-11-25T17:36:12Z")

</div>

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

```choicescript
*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?

---

<div class="post-metadata">

**Author:** ![Stewart\_Baker](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stewart_baker/32/184264_2.png) [@Stewart\_Baker](https://forum.choiceofgames.com/u/Stewart_Baker)\
**Post date:** [November 25, 2023, 5:56pm UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/6 "2023-11-25T17:56:24Z")

</div>

> [@ArchivistAlpha096](#):
>
> ```choicescript
> *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
> 
> ```

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](https://choicescriptdev.fandom.com/wiki/Indentation).

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.

---

<div class="post-metadata">

**Author:** ![ArchivistAlpha096](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/archivistalpha096/32/203655_2.png) [@ArchivistAlpha096](https://forum.choiceofgames.com/u/ArchivistAlpha096)\
**Post date:** [November 25, 2023, 9:21pm UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/7 "2023-11-25T21:21:32Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![will](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/will/32/132033_2.png) [@will](https://forum.choiceofgames.com/u/will)\
**Post date:** [November 25, 2023, 10:24pm UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/8 "2023-11-25T22:24:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/choiceofgames/original/3X/e/f/efe1497a762edecdb6d569a1c4abee87508bf002.png) [@system](https://forum.choiceofgames.com/u/system)\
**Post date:** [November 26, 2023, 10:25pm UTC](https://forum.choiceofgames.com/t/game-throwing-up-an-error-about-a-number-due-to-an-if/145310/9 "2023-11-26T22:25:32Z")

</div>

Closed on November 26, 2023, 10:25pm UTC

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