I'm getting an error, please help

I’m getting an error like is:…
8614cf05b2d0a7e06fd670e0c76f076eaecc7ae4_1_690x305

My code looks like this:

Any help would be lovely

Instead of *elseif (gender = “boy”) try simply *else.

You want *if statements to go like this:

*if/*else
or
*if/*elseif/*else

But it’s never just *if/*elseif.

2 Likes

Also a potential problem is there is another option for Clay besides “boy” and “girl”–quicktest may think there may be another option and bug out. Another reason it is better to use *else.

1 Like

This isn’t exactly an answer to your question, but here’s something else you can do to make your coding easier: instead of the whole *if (gender = "girl")... *else... phrase, you could use ${} or @{} notation:

With ${} notation, you define a variable in the startup.txt file, e.g.:

*create himher ""

And then set it along with the gender variable as “him” or “her”, before using it in your code like this:

Get away from ${himher}!" he yelled, with a dangerous look in his eyes.

You could then use it over and over again within the script.

@{} notation isn’t initialised at startup, but instead defined as needed in the script, as so:

Get away from @{(gender = "girl") her | him}!" he yelled, with a dangerous look in his eyes.

(Note the pipe symbol “|” between “her” and “him”.) This is probably less useful in this situation, as you’d need to write it out every time you use it.

6 Likes

Thank you so much! I have it fixed now!

Since ChoiceScript has no way to know if "girl" and "boy" are the only possible values for the gender variable, it’s going to assume, rightly or wrongly, that it’s possible for the player to have a value for their gender variable that’s something else. Likewise, CS has no way to know if 80, 90, and 100 are the only possible values for the Health variable. You know why Health cannot be 92 or 77 or 13 or, well, anything else… but CS doesn’t know that.

As @Gower mentioned, you can fix this by using *else instead of both *elseif (gender = "boy") statements and the *elseif (Health = 100) statement.

However, I notice that every single one of these *if and *elseif statements send the game to the same scene. You may be able to replace all of your *elseif statements with *if statements, which will allow you to remove or consolidate the *goto commands. You also have some repeated text that could be condensed. Something like so:

Clay stands at the Mart doorway in shock.
The bag in his hands drops as he rushes over
*if Health = 80
    to your injured form. "Get away from
    *if gender = "girl"
        her!"
    *if gender = "boy"
        him!"
    He yelled, with a dangerous look in his eyes.
*if Health = 90
    to pry the guy away from you. "Get away from
    *if gender = "girl"
        her!"
    *if gender = "boy"
        him!"
    He yelled, with a dangerous look in his eyes, lifting him easily by the collar and throwing him to the side.
*if Health = 100
    to your side.
*goto_scene page20

How does that trick work? Fairly simple, actually. If two lines of narration or dialog have nothing between them, ChoiceScript will automatically display them to the player as a single line with a single space between them. Examples:

This is actually
all one line,
at least when
the player sees it.

This is a separate line, because of the empty lines above and below.

This will display as two lines that touch,
*line_break
because of the line break command.

That will display as:

This is actually all one line, at least when the player sees it.

This is a separate line, because of the empty lines above and below.

This will display as two lines that touch,
because of the line break command.

As @ParrotWatcher says, you can also create variables just for displaying pronouns for characters. So at the beginning you may have:

*create gender ""
*create they ""
*create them ""
*create their ""
*create theirs""

Then a bit later, when the player defines their character’s gender, your code may look something like:

*fake_choice
    #I'm a woman.
        *set gender "girl"
        *set they "she"
        *set them "her"
        *set their "her"
        *set theirs "hers"
    #I'm a man.
        *set gender "boy"
        *set they "he"
        *set them "him"
        *set their "his"
        *set theirs "his"

With pronoun variables like that, you could simplify your code even more. Like so:

Clay stands at the Mart doorway in shock.
The bag in his hands drops as he rushes over
*if Health = 80
    to your injured form. "Get away from ${them}!"
    He yelled, with a dangerous look in his eyes.
*if Health = 90
    to pry the guy away from you. "Get away from ${them}!"
    He yelled, with a dangerous look in his eyes,
    lifting him easily by the collar and throwing him to the side.
*if Health = 100
    to your side.
*goto_scene page20
5 Likes