HTML twine sugarcube, between variables

AndWhy

Newbie
Oct 31, 2020
35
25
I recently started playing around with twine sugarcube 2 and so far it's been pretty neat. But I've been staring at the same problem for over 2 hours now and don't know what's wrong.
I've added a random roll and depending on the roll you get different outcomes. Roll 1-20, 1 is critical fail, 2-9 is fail, 10-19 is success and 20 is critical success. How am I supposed to make the <<if>> statement react appropriately ?
So far my code is:
<<set _check to random(1, 20)>>\
You roll a _check !
<<if _check lte 1>>\
You stumble about and fall, giving you a laughable apperance. <<set $dominance to $dominance -3>>
<<elseif _check gt 1 and lt 10>>\
You don't find any food and feel like a failure. <<set $dominance to $dominance -1>>
<<elseif _check gte 10 and lt 20>>\
You gather enough food for 10 meals.<<set $food to $food +10>>
<<elseif _check gte 20>>\
You land some big game and gather enough for 20 meals.<<set $food to $food +20>><<set $dominance to $dominance +1>>
<</if>>

And I get: Error: <<if>>: bad conditional expression in <<elseif>> clause (#1): expected expression, got '<'

Dafuq does this even mean??!?
Please help.
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,142
4,036
I recently started playing around with twine sugarcube 2 and so far it's been pretty neat. But I've been staring at the same problem for over 2 hours now and don't know what's wrong.
I've added a random roll and depending on the roll you get different outcomes. Roll 1-20, 1 is critical fail, 2-9 is fail, 10-19 is success and 20 is critical success. How am I supposed to make the <<if>> statement react appropriately ?
So far my code is:
<<set _check to random(1, 20)>>\
You roll a _check !
<<if _check lte 1>>\
You stumble about and fall, giving you a laughable apperance. <<set $dominance to $dominance -3>>
<<elseif _check gt 1 and lt 10>>\
You don't find any food and feel like a failure. <<set $dominance to $dominance -1>>
<<elseif _check gte 10 and lt 20>>\
You gather enough food for 10 meals.<<set $food to $food +10>>
<<elseif _check gte 20>>\
You land some big game and gather enough for 20 meals.<<set $food to $food +20>><<set $dominance to $dominance +1>>
<</if>>

And I get: Error: <<if>>: bad conditional expression in <<elseif>> clause (#1): expected expression, got '<'

Dafuq does this even mean??!?
Please help.
The 'and' operator requires a boolean expression after it. You can't chain several gt/lt/etc like you do. So do this:
<<elseif _check gt 1 and _check lt 10>>
and
<<elseif _check gte 10 and _check lt 20>>
 
  • Like
Reactions: AndWhy