Howdy, Stranger!

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

Is it possible to have more than one correct answer for a variable?

Hello,
I'm trying to make a puzzle, the solution of which is a birthdate. Because of different date conventions, I want to allow for February 14 1990 to be entered into the text macro as "140290" and "021490" and have both be correct.

The problem I have is that my code currently allows any string to be correct.

The text macro is
The middle container is sealed with a single combination lock. There are six numbers.

<<textinput $container3code container3open>>


and in the passage "container3open" the code is
<<if $container3code is "021209" or "120209">>You opened container 3!
<<else>>
That doesn't seem to be the right code.

Try again?
<<textinput $container3code container3open>><<endif>>
containers

If I enter "12345" it simply accepts it and prints "You opened container 3!"

Am I approaching this wrongly? What is a better way to allow multiple correct answers whilst filtering out incorrect ones?

Comments

  • You need <<if $container3code is "12345" or $container3code is "98765">>
  • edited November 2016
    I had a similar problem. I'd keep getting if statements to verify as true for textinput when the textinput was set to " " blank string.
  • I had a similar problem. I'd keep getting if statements to verify as true for textinput when the textinput was set to " " blank string.

    Copy your code here so that people can take a look.
    if $container3code is "021209" or "120209"
    

    means exactly as it is. Either $container3code is "021209", or "120209" is a string. "120209" is always a string, no doubt, so you always get TRUE as an answer.
Sign In or Register to comment.