Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[Harlowe] Checking a variable to see if it's between two numbers

edited November 2016 in Help! with 2.0
I'm making a game based around a character's opinion of you, and I'd like to have three possible outcomes: they LOVE you ($opinion > 6), they HATE you ($opinion < 2), or they're AMBIVALENT ($opinion between 2 and 6).

I'm not sure what expressions to use in order to check for something that is BETWEEN two numbers!

I've even tried an inelegant solution of just duplicating (if: $opinion = 2), (if: $opinion = 3), etc all the way up to 6, but that results in the following error: (if:)'s 1st value is an assignment operation, but should be a boolean.►

Comments

  • You could use an and operator to check if a value is between two values:
    (if: $opinion >= 2 and $opinion <= 6)[You are AMBIVALENT]
    

    But based on your example I would use an (if:) / (else-if:) / (else:) macro combination:
    (if: $opinion > 6)[they LOVE you]
    (else-if: $opinion < 2)[they HATE you]
    (else:)[they're AMBIVALENT]
    
    ... this works because if either of the first two conditions are not true then the value of $opinion must be between 2 and 6 inclusively.
Sign In or Register to comment.