What's wrong with this code?
kyrathasoft
26 Aug 2022, 15:20squiffy.set("randomnumber", Math.floor(Math.random() * 20) + 1);
You rolled a {randomnumber}.
{if randomnumber > 10: A decent result...}{else: Hmm, not too good...}
The above always prints 'A decent result', even when the roll is 10 or less...
IFforClassroom
27 Aug 2022, 23:02There should be no spaces in your ">" statement.
{if randomnumber>10: A decent result...}{else: Hmm, not too good...}
However there's also an old bug in ">" and "<" statements that's caused me pain and suffering from time to time. So if this doesn't work, try:
{if randomnumber>=11: A decent result...}{else: Hmm, not too good...}
OR
{@randomnumber+=1}
{@randomnumber-=1}
{if randomnumber>10: A decent result...}{else: Hmm, not too good...}
If it continues to cause you unwarranted agony, just go with javascript if statements.
mrangel
28 Aug 2022, 10:15Yeah… everything between the colon and the greater than/less than sign is taken as the attribute name. So it's looking for an attribute named randomnumber
including the space.