This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
if [2014/02/03 06:09] l [Usage] |
if [2017/10/09 20:39] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <- [[remember|Remembering Things With Variables]] --------- [[nobr|Removing Line Breaks]]-> | ||
+ | |||
=====<<if>>===== | =====<<if>>===== | ||
Line 13: | Line 15: | ||
>%%<<%%if //expression//%%>>%% //Text// %%<<%%else if //expression//%%>>%% //Text// ... %%<<%%endif%%>>%% | >%%<<%%if //expression//%%>>%% //Text// %%<<%%else if //expression//%%>>%% //Text// ... %%<<%%endif%%>>%% | ||
- | //condition// is an [[expression]] that can evaluate to true or false. //Text// is any amount of passage text that you wish to display only if the condition is //true//. <<endif>> is a macro tag indicating the end of the <<if>> macro invocation. | + | //expression// is an [[expression]] that can evaluate to true or false. //Text// is any amount of passage text that you wish to display only if the condition is //true//. <<endif>> is a macro tag indicating the end of the <<if>> macro invocation. |
Note that the //Text// can contain any Twine code, including an inner <<if>> invocation: | Note that the //Text// can contain any Twine code, including an inner <<if>> invocation: | ||
- | <<if $body is "wounded">>You are <<if $blood < 5>>about to die<<else>>bleeding<<endif>>. Seek help!<<endif>> | + | <<if $body is "wounded">>You are <<if $blood <= 5>>about to die<<else>>bleeding<<endif>>. Seek help!<<endif>> |
====Motivating example==== | ====Motivating example==== | ||
Line 97: | Line 99: | ||
(Note: if you prefer, you can also write "else if" as "elseif".) | (Note: if you prefer, you can also write "else if" as "elseif".) | ||
else if | else if | ||
+ | |||
+ | <- [[remember|Remembering Things With Variables]] --------- [[nobr|Removing Line Breaks]]-> | ||
+ |