Some problems with *selectable_if & *if statements

Hello there, folks, it’s Silhuetta, back again with one of the many coding problems that I have bashed my head against while coding. Specifically, the error occurs when I try to put in *seletable_if or *if statements in a choice. For example, if I type:

*choice
    *if (mute) or (deaf) #You raise your head, giving ${tn} a frosty glare.
        *set stoic %+10
        *goto awakeningpowers
    *selectable_if (mute = false) #"Nobody sent me...I think." Furrowing your brow, you attempt to call back any memories that you might've had. But all you get is static; white blurry images that form no cohesive answer.
        *set honesty %+10
        *goto awakeningpowers
    *selectable_if (mute = false) #"Screw you," you spit, shooting ${tn} a disdainful look.
        *set impulsive %+10 
        *goto awakeningpowers

It gives me "Invalid expression at char 5, expected OPERATOR, was: CLOSE_PARENTHESIS [)]

The problem line here is the *if statement.

On the other hand, if I try to write it like this:

 *selectable_if (mute) or (deaf)

It gives me the same error. I don’t know if CS allows people to test several variables in a *seletable_if , but I don’t want to write out two separate choices for something that has the same outcome.

If I’m not mistaken statements with more than one variable to test for need to be wrapped within the *if’s “()”'s

Like so:

*selectable_if ((condition 1) or (condition 2))

Or

*if ((condition1) or (condition2))

It worked, thanks for the help. :grin:

I assume that you would need to do the same if you were putting an *if ((variable1) and (variable2))?

Np.

Yes, that’s correct.

Ah, and I forgot one other thing.

Would *if not statements fall into this category as well?

I’m guessing it would look something like this:

*if (not (variable1))

Well, that looks like I butchered it.

…there’s a “not” operator in CS?

No, seriously, this is news to me, but err… that aside, could one not simply do the same thing like so?

*if (condition1 = false)

Or

*if ((condition1 = false) and (condition2 = false))

EDIT: Try this and see if it works, I have a hunch that that statement is not working because you’re double wrapping, which you only need do if there’s more than one condition you need to check:

EDIT AGAIN: Actually, you’d need a condition to check against in the first place (I’ve edited the code to reflect so please try it and do tell if it works).

*if (variable not condition)

Of course replace “condition” there with the condition and “variable” with the variable to check.

I never use it (it doesn’t fit neatly into my pattern for easier reading), but I think not is has to be written without a space between it and the parentheses, such as not(foo).

Just did a bit of testing on my end, the problem lies neither with the space or lack of one or double wrapping (all work fine). It’s the type of variable you are using not on. With a boolean (true/false) this syntax works perfectly fine:

*if not (foobar)
----*set //set what happens if foobar is false here

However with a string or numeral you need something to check against in order for CS to return whether it’s true or not so with a numeral or string your syntax’d look like this:

*if not (boop = “red”)
----*set //set what happens if boop is not “red” here

Slightly confusing context for not, but that’s how it works (at least on my end).

You can also use != for does not equal… so

*if (boop != "red")
  Boop is not red!
*if (boop = "red")
  Boop is definitely red today.
1 Like

I frequently write “*if mute or deaf” with no parentheses at all and it works fine.

But I pop the consequence on the next line down rather than fitting it all into a single line of code. I suspect that when you want it on a single line, *if (like *selectable_if) needs everything inside one parenthesis.

For two booleans, you should be able to dispense with the internal parentheses though. Try *if (mute or deaf) and see how it works for you.