Need a reminder: How do I do these determinators?

I know there’s a way to have an *if etc with various determinators that are unrelated to each other.

like if I have something like this:

*if (((A = 1) and (B = 1)) or (B = 2))

It means that it’s either triggering if A and B are BOTH 1 or if B is 2.
But what if I want something to trigger if, e.g. A and B are both 1 OR B AND C are both 2.

Do I write it like this:

*if ((((A = 1) and (B = 1)) or (B = 2)) and (C = 2))

Because I remember vaguely there was a way to NOT have an onslaught of ( at the beginning of the *if and still have things work as intended.

1 Like

I’m not aware if there’s such a command. I’d just pull them into a *goto line instead.

*if ((A = 1) and (B = 1))
  *goto merge
*if ((B = 2) and (C = 2))
  *label merge
  Text here.

That would be

*if ((A = 1) and (B = 1)) or ((B = 2) and (C = 2))

Generally, I find it best to break up long conditionals into multiple lines. If they’re homogenous, all and or all or, that’s one thing, but if you’re mixing both in a single line, it can get hard to follow.

Stacking conditions above eachother as ColossalKitten did is one method, effectively oring them together; nesting one condition within another is equivalent to and.

Another method that can be useful if you have a lot of possible conditions that might trigger the code is to set a *temp variable tracking them:

*set num 0
*if (A = 1) and (B = 1)
   *set num 1
*if (B = 2) and (C = 2)
   *set num 2
*if (C = 3) and (D = 3)
   *set num 3

...etc...

*if num >= 1
   Text here.

Keep in mind that the order matters; whichever true condition is listed last will set the final value of the *temp variable. (Or use *elseif if you want to only pick the first condition that’s true, instead.)

Then you can use that temporary value to flavor the text displayed with a multireplace, even if it doesn’t change anything mechanically:

@{num The pine trees are|The mountain is|The sea is} beautiful.
8 Likes

If you want a bit fancy, try

*if B = 1
   *if A = 1
      asdfsdaf
*elseif B = 2
   *if C = 2
      fdsafdsa
2 Likes

Well, I’m trying to reduce the total wordcount, so…

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.