Ultimate Noob Coding

Can you post the whole code for the choice this segment appears in?

The code you posted works fine for me.

Only modification was removing 2 levels of indents from each line.

I suspect your error is happening in the broader choice, or maybe in wild7.txt.


Is that something ChoiceScript used to require in the past?

Because I use *if/*elseif without a final *else all the time. I typically don’t need–or want–a catchall.

For a really slapdash example:

This compiles and passes both QT and RT.

*create strength 50
*create charisma 50
*create dragon_regard 1
*rand strength 15 85
*rand charisma 15 85

(Strength is ${strength}, Charisma is ${charisma}.)

You meet a dragon.

*if strength > 65
    "I have heard impressive tales of your strength," the dragon says. "I admire that greatly."
    *set dragon_regard + 3
    *goto gold_pile
*elseif charisma > 75
    "People speak highly of your oratory skill," the dragon says. "I'm something of an orator myself."
    *set dragon_regard + 2
    *goto gold_pile
*elseif (strength > 60) and (charisma > 60)
    "People say you are quite a skilled individual," the dragon says.
    *set dragon_regard + 1
    *goto gold_pile

*label gold_pile

The dragon regards you cautiously, basking languidly atop a pile of gold coins.
*ending

In my opinion:

  1. *if/*if/*if... is for outcomes that aren’t mutually exclusive or mandatory. You want to show multiple extra bits to some players.

  2. *if/*elseif(s) is for outcomes that are mutually exclusive but not mandatory. You want to show exactly one of multiple possible extra bits to some players.

    (While you could use a series of *ifs, IMO it’s better coding practice to clearly communicate your intent for the outcomes to be mutually exclusive. For yourself and any reviewers.)

  3. *if/*elseif(s) [optional]/*else is for outcomes that are mutually exclusive and mandatory. Everyone needs to get exactly one bit.

    Some people also use final *elses to throw *bugs or display error text as a debugging strategy.

2 Likes