I am trying to build a combination lock in my game. I can get the variable assignments to work, and the response. The problem is even when the wrong combination is entered it still says lock opened.
I’m pretty sure I am doing something wring in the if/elseif statements but can’t figure out what.
Here is what I am working with.
You see here a lock. Can you crack the combination?
The dials read:
<<set $dial1 = "Three">><<cyclinglink "Two" "Three" "Four">>
<<set $dial2 = "Blind">><<cyclinglink "Mute" "Blind" "Deaf">>
<<set $dial3 = "Mice">><<cyclinglink "Goats" "Mice" "Voles">>
[[Open it!|Open]]
<<if $dial1 is "Three" and $dial2 is "Blind" and $dial3 is "Mice">> You opened the lock! Unfortunately the suitcase lock isn't actually attached to a suitcase, but it's still a decent accomplishment.
<<else>> Blast! That wasn't the combination!
<<back>>
<<endif>>
That will randomly display one of three comments if they try the wrong combination (edit the _comment array to change the number and/or type of comments), or send them to the “Open” passage if they try the correct combination.
Please let me know if you have any questions about how that works.
If _count isn’t defined, which it won’t be initially, then it sets it to 1, otherwise it adds 1 to it (the “++” operator means “add 1”, for specifics see the increment operator). At four failures it then sends you to the “Alarm” passage.