If statements not working. Again

Twine Version: 2.4.1
Story Format: 2.36.1
Hello! I need help. My if statements aren’t working. I used the code like this:

<<if $airint lte 10>>He absolutely <span style="color:red">''hates''</span> you.<<elseif $airint lt 30 gte 10>>He <span style="color:#FF69B4">''dislikes''</span> you.<<elseif $airint lt 50 gte 30>>He considers you an <span style="color:#367588">''aquaintance''</span>.<<elseif $airint lt 70 gte 50>>He is your <span style="color:#99EEBB">''friend''</span>.<<elseif $airint lt 90 gte 70>>He is your <span style="color:#21ADA8">''close friend''</span>.<<elseif $airint gte 90>>He is your <span style="color:green>''bestfriend''</span>.<</if>>

But when I go to look at it, it just shows nothing. Am I doing something wrong? If so, how do I make it so it works? Thank you!
(Also, $airint is set to 30.)

The elseif statement is showing if $airint is less than 30, print this. But $airint is 30, which makes this statement false. It has to be greater than 10 and less than or equal to 30.
Try <<elseif $airint gt 10 and $airint lte 30>>.

1 Like

While it would be really awesome to do so, the <<if>><</if>> macro doesn’t allow to compare values like you tried. You need to write each of these comparisons in full, separated by || (or) or && (and).

For instance:

<<elseif $airint lt 30 && $airint gte 10>>

However, you don’t need to precise the greater than part, because if it is not greater than, it falls in one of the previous tested conditions.

Also, you missed a double quote in the last style.
Last, you could use <<else>> for the last line. the advantage is you have less chance to make a blunder if you don’t have to write the full condition.

<<if $airint lte 10>>He absolutely <span style="color:red">''hates''</span> you.
<<elseif $airint lt 30>>He <span style="color:#FF69B4">''dislikes''</span> you.
<<elseif $airint lt 50>>He considers you an <span style="color:#367588">''aquaintance''</span>.
<<elseif $airint lt 70>>He is your <span style="color:#99EEBB">''friend''</span>.
<<elseif $airint lt 90>>He is your <span style="color:#21ADA8">''close friend''</span>.
<<else>>He is your <span style="color:green">''bestfriend''</span>.<</if>>

Thank you! I tried it and it worked. Thank you so much!!

Thank you! I’ll try it.