Countersong's Closet

Click here to edit subtitle

ChoiceScript Tutorial

 

ChoiceScript Tutorial Part 3: Putting Your Stats To Use

Now that you have some variable stats, you can alter the text to reflect the changes.

The *if, *elsif, and *else commands can help you change small portions of text based on earlier decisions.

  • The condition behind the *if command will always be checked by ChoiceScript.
  • The condition behind the *elsif will only be checked if the conditions behind the previous *if or *elsif were not met.
  • ChoiceScript will default to the *else command if no *if or *elsif conditions above it are applicable.


Each of these commands creates a block under it, much like the *choice blocks, and require indentation for everything that you want to happen when that condition is met.

Don't forget to add a *goto, *goto_scene, or *finish to each of these three blocks. Otherwise an error will occur.

Tip:

You can add two or more conditions to one command with "and" or "or". These conditions must be grouped in sets of two with parentheses like in an algebraic equation:


*if (stat_1 > 10) and (stat_2 < 5)

*elsif ((stat_1 > 10) and (stat_2 <= 50)) or (stat_3 != "name")

*elsif ((stat_1 >= 5) and (stat_2 < 75)) and ((flag_1) or (flag_2 = false))


Note that for true/false conditions you can simply put the condition name in parentheses if it's true, or follow it with = false if it's not.

Also, the != (not equal) can be used if you want to indicate that a stat can equal anything but the following value.

You can make more complex conditions, but try not to use more than you need. It can make things frustratingly complicated to keep up with and adds little, if any, value to most games.