Ranged Variables (Solved)

Quick question for variables. I know if you do something like this Stat <50 it means that if the stat is below 50 then whatever happens, happens. But is there a way to make a range for the variables where if the variable is between 20 and 40 then something happens.

I think that doing it like “If variable >20 and variable<40 Then” would probably work.

2 Likes

That should do. And I need to post at least 20 characters so I’ll just acknowledge that so the character count goes well above it.

like they said

*if (variable > 20) and (variable < 40)
    something happens

if you want to include 20 and 40

*if (variable >= 20) and (variable <= 40)
    something happens

2nd half thanks to @Szaal
this page might help

2 Likes

It’s actually

*if (variable > 20) and (variable < 40)

If you want the number 20 and 40 to be included in the check, add = after the inequality signs.

2 Likes

Wouldn’t it need to be a double parentheses? I may have overthought it but I always expressed these as *if ((variable > 19) and (variable < 41))

I’ve never used a check between two variables, but I assume it needs a double, probably, like everything else.

Referring to the wiki, it shows two variables can be shown in seperate pharanteses but for more than two, you need an extra pharantesis, as variables can only go in pairs. The example in the wiki is;
This is correct :point_down:

*if (var1 > 10) and (var2 > 20)

This is wrong :point_down:

*if ((var1 > 10) and (var2 > 20) and (var3 > 30))

This is correct as well :point_down:

*if (((var1 > 10) and (var2 > 20)) and (var3 > 30)) 

Honestly i didn’t know about the last one. I would put the third variable seperately but appearently that works as well :smirk:

For more info the wiki is here

3 Likes