if
statementsif
statements.if
statement allows you to control whether a collection of content is shown or not. When you write an if
statement, you provide an expression, which is checked; if that expression evaluates to a "true" value, then all of the content in between the <<if>>
and <<endif>>
statements are run.$gold_amount
, to 5. It will then show the line "I'd like to buy a pie!", and before it continues, it will check to see if $gold_amount
is less than 10. If that's the case (which it will be!), the line "Well, you can't afford one!" will run.elseif
and else
elseif
and else
statements to handle different situations in an if
statement.elseif
statement has an expression that gets checked if the if
statement, or any previous elseif
statements, don't run.else
statement doesn't have an expression, and runs$gold_amount
. The checks are done from top to bottom, which means that in order for an elseif
or else
to run, all of the checks above it have to have failed.if
and elseif
statement must result in a boolean value (that is, true or false.) For exame,<<if 1>>
isn't allowed, but <<if 1 == 1>>
is.$reputation
, you might want to make certain options only available if the value of $reputation
is high enough.if
statement to the end of the option. They look like this:if
statement. If the expression is false
, then the option will be marked as unavailable.