Multiple Variables for *if statements

Is it possible to have something like:

*if (condition_one), (condition_2)

Where you are asking if both variables are true? i.e, in this example if condition_one AND condtion_two are true.

Thanks!

I always have trouble getting things to depend on multiple variables but i think its

*if (something =true) and (thing =true)

Can someone say if i am right?

Reaperoa told me that it should be like this:

*if ((some_shit = true) and (other_shit = true)).

A parenthesis for every two variables.

3 Likes

i thought that was only if it was a *selectable_if ?

I’ve gotten into the habit of doing all multiple conditions as ScarletGeisha shows there, with extra parenthesis around each pair, as that way avoids any problems. The only thing to watch out for (as it won’t be an error, just an incorrect calculation) is the different between AND & OR when both are used within the same condition. Double-check your logic on those (or even run some tests) to make sure the condition is saying exactly what it’s supposed to in all cases.

…You’ll understand that better when you’re using 4+ conditions for a single *if and are mixing ANDs & ORs on the same line!

@appleduck28 Technically, you don’t need the outer parentheses if you’re just using an *if (although you do need them around each equation), so:

*if (foo = true) and (bar = true)

does work. But there are some cases (like using *selectable_if) where you do need the outer parentheses, so it’s usually a good habit to get into (particularly as the extra parentheses never hurt).

@Daemonion There are two things to remember that aren’t always mentioned though: The first thing to remember is that each AND/OR will only connect two equations, so if you want to check if all of foo, bar and bat are true you’ll need to use:

*if ((foo = true) and (bar = true)) and (bat = true)

(Bolded the parenthese that are necessary but very easy to forget.)

The other thing to remember is (as mentioned by @Vendetta) mixing and matching AND/OR with the correct order of parentheses can be confusing at the best of times. Once you get a hand on how the logic works though, you may be surprised at how simple it can be, but while starting out, you’ll probably want to stick with each *if command only use AND or OR.

1 Like

Excellent. I haven’t even used any OR statements yet.

Are these scenarios possible:

*if ((one = true) and (two = true)) and ((three = true) and (four = true))
stuff

*if ((you_killed_spongebob = true) or (reaperoa_killed_spongebob = true))
spongebob is dead! :frowning:

1 Like

Yep, both are fine. In the first example, *if is true only if all four of those conditions are true, whereas in the second example *if is true if either one of those conditions is.

1 Like

Awesome! Thanks, guys!

hey everyone, no matter what i try, the if command does not seem to take the stats into account, ive tried

if var = 80 and if var >80, even if var >=80

Either of those should work if the code surrounding it works like it should, but let’s keep this discussion on one thread, shall we?

sure thing, no problem