ChoiceScript Wiki
ChoiceScript Wiki

   The *elseif command (also spelled *elsif) is only used after an *if command to specify an alternative if the initial *if condition fails.


As noted in *if article, ChoiceScript has a top-down prioritization. That being said, here's how to use it:

*if happiness <= 10
    You're very sad.
*elseif (happiness > 10) and (happiness <= 50)
    You're sad.
*elseif (happiness > 50) and (happiness <= 70)
    You're moderately happy.
*elseif (happiness > 70) and (happiness <= 90)
    You're happy!
    You're very happy!

This setup ensures there's only one possible outcome to be met (happiness less than 10, happiness 10~50, happiness 50~70, happiness 70~90, and a general catch condition — which, in this case, should cover happiness 90~100). If the first condition isn't true (if happiness is equal to 30 for example), the code will check if the next block fits the specified condition. In this example, if all the blocks fail, the output will default to "You're very happy!" because of the general catch condition *else statement at the end.

More commands / functions
Choice *choice, *fake_choice, *disable_reuse, *hide_reuse, *allow_reuse, *selectable_if
Variable *create, *temp, *set, Arithmetic operators, *delete, *input_number, *input_text, *print, *rand
Conditional *if, *elseif, *else, Multireplace
Goto *label, *goto, *goto_scene, *goto_random_scene, *gosub, *gosub_scene, *finish
Formatting Bold text, Italic text, *image, *line_break, *page_break, *link, *stat_chart
Miscellaneous *comment, *scene_list, *title, *author, *achieve, *achievement, *check_achievements, *bug, *ending, *more_games, *share_this_game, *show_password, *script, Implicit Control Flow