0 votes
by (1.4k points)

Hello friends!

Using SugarCube 2.21, and I am using a system of nesting <<if>> macros inside each other to get it to do what I want, like this:

<<link test>><<set $test to 1>><</link>>
<<link Test>><<set $Test to 2>><<if $test eq 1>><<if $Test eq 2>><<audio "key01" play>><</if>><</if>><</link>>

and I was wondering if there was a better way.

Thank you all!

1 Answer

0 votes
by (159k points)
selected by
 
Best answer

If you look at the TwineScript conditional operators section of the <<if>> macro documentation you will see examples of how to use the and operator and the or operator.

<<set $varA to 1>>
<<set $varB to 2>>

<<if $varA is 1 and $varB is 2>>Both of the variables equalled the relevant values.<</if>>

<<if $varA is 1 or $varB is 2>>At least one of the variables equalled the relevant value.<</if>>

 

by (1.4k points)
Thank you! I thought there might be something like that, but did not remember seeing anything in the documentation.
This site has been placed in read-only mode. Please use the Interactive Fiction Community Forum instead.
...