Howdy, Stranger!

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

Using More Than One Variable in an If/ElseIf/Else Statement in Harlowe

Hello all.

pfm2001 here.

I'm here to ask about how to use more than one variable in If/ElseIf/Else Statements in Harlowe, as it produces an error when I do the following: (This was a test)

(if: $assist and $help are "true")[nice]
(elseif: $assist is "true")[go back]
(elseif: $help is "true")[stop]
(else:)[what]

Am I doing this wrong?

I know how to assign variables ( (set: $assist to "true") etc.), but this doesn't seem to work. Any solutions?

Comments

  • You should be using the Boolean values true and false instead of the String values "true" and "false", if you do that then you code example would look like the following.

    note: I added (set:) macros to the following to show how to assign the Boolean true and false to a variable.
    (set: $assist to true)
    (set: $help to false)
    
    (if: $assist and $help)[nice]
    (else-if: $assist)[go back]
    (else-if: $help)[stop]
    (else:)[what]
    
    
    ''Check if a Boolean variable is equal to false. (eg. not true)''
    (if: not $help)[help variable is not true, so there-for it's false]
    

    The following answer your question about multiple variables in one (if:) macro when the variables contain either String or Numeric values. It also shows how to assign multiple variables within a single (set:) macro.
    (set: $name to "Jane", $age to 20)
    (if: $name is "Jane" and $age is 20)[Your name is Jane and you are 20 years old.]
    
  • Oh, thank you! I'll try it!
Sign In or Register to comment.