Is it not possible to have an *if statement for a choice that checks two variables?


#1

I keep getting various errors when attempting to have a choice appear only if TWO variables are met. Example:

*choice 
    #"Nothing. Go back inside."
        Blah blah.
    #"I think I'll come in."
        Blah blah.
    *if (gender = "Female") and (romanced >= 3) #"Could you stay?"

The most common error that I’m getting is “Invalid expression at character 18: expected no more tokens, found: CLOSE_PARANTHESIS [)].” But adding parantheses ((gender = “Female”) and (romanced >= 3)) also results in an error. Am I missing something really obvious here?


#2

This may or may not work, but…try putting the option on the line after the *if, indented, like so?

*choice 
    #"Nothing. Go back inside."
        Blah blah.
    #"I think I'll come in."
        Blah blah.
    *if ((gender = "Female") and (romanced >= 3))
        #"Could you stay?"

#3

WOW I FEEL LIKE AN IDIOT.

This will teach me to try to code at 1 AM! Thank you, that worked perfectly! :sweat_smile::upside_down_face:


#4

No worries! I’ve done plenty of interesting things whilst coding at one am (and one pm, for that matter…). It’s a bit confusing because *selectable_if and the like do very nicely on the same line, so it’s easy to get them muddled.


#5

Yes! And I’m fairly sure *if has worked on the same line for me before… but the fact that I can’t remember now should say something! Off to bed for me… I can sleep better knowing that you solved the problem, haha!


#6

I actually seemed to have the same error if one of the ifs was comparing things between “”. If it was comparing other things like numbers and had the proper double parenthesis set up, it seemed to work fine.

I think that turning implicit control flow on solved that, as I’m not getting that error anymore (it’s been a long time since I tested it though); try using that and reverting to the one line before and see if it works?

Implicit control flow is off by default. To use it, you have to *create implicit_control_flow true in startup.txt.


#7

WHAT IS THIS IMPLICIT CONTROL MADNESS? I never even knew about this! Whoa, you just opened a whole new door for me! Thank you! :scream::bowing_woman:t2: