Using multiple switch scripts.

Jsimmons
25 Apr 2020, 15:50

So, in my game, I've got two place where the player needs to type something in to access the next part of the game. Once with a keycode, and once with a text password. I used "Get input" and "Switch" Scripts to make both of these.

First script:

switch (result) {
  case (3242) {
    msg ("The screen flashes green and the door unlocks with a click.")
    UnlockExit (BackDoor)
  }
  default {
    msg ("The buttons flash red and the keypad buzzes. Your code is incorrect.")
  }
}

Second script:

msg ("Password:<br/><br/>Hint: You are standing in a room with an all southern view. Suddenly a bear walks by the window. What color is the bear?")
get input {
  switch (result) {
    case (red) {
      msg ("That's an absurd answer.")
    }
    case (white) {
      ClearScreen
      msg ("Congrats you did it!")
    }
    default {
      msg ("Incorrect.")
    }
  }
}

So I've used "result" for both of these, which results in the only correct answer for the second script being the correct one for the first: the number 3242. But when I try to use another variable: "text" or "code" or something, it doesn't work. I don't know how to fix this, and I can't find an example in the documentation.


Jsimmons
25 Apr 2020, 16:54

I think I figured it out. It had nothing to do with "result" but with the fact I didn't put quotes around my text cases in the second script...

Punctuation.