Making a player type a command (using if result)

J_J

I have a scene where the player needs to type "wake up" this stops a timer that is writing the phrase wake up, and transports the player to a different room. It works... but only if the player ONLY types "wake up." If they type anything else the else msg runs (one time). Then after that they can interact with the objects in the game normally, and the "wake up" command no longer works... meaning that the timer just continuously types wake up.

What am I doing wrong?

else if (Got(subway vending water)) {
  firsttime {
    msg ("msg")
    if ((GetBoolean(phone, "SamTalk")) and (not Got(sam phone number))) {
      msg ("description.")
      MakeObjectVisible (sam phone number)
      AddToInventory (sam phone number)
    }
  }
  otherwise {
    MakeObjectInvisible (subway vending water)
    msg ("description, fall asleep.")
    SetTimeout (1) {
      EnableTimer (wake up)
    }
    SetTimeout (1) {
      picture ("firstdreamsequence.gif")
    }
    get input {
      if (result = "wake up") {
        msg ("You wake up.")
        DisableTimer (wake up)
        MoveObject (player, Sketchy Room)
      }
      else {
        msg ("bla bla msg?")
      }
    }

What goes wrong?

It looks like the picture will display no matter what, but that's just a guess...

...but what does it do and what does it not do?


J_J

The picture displays, and the timer runs (which types out "wake up" underneath the animation). If the player ONLY types "wake up" it works perfectly: the timer stops, and they are transported to a different room. If they type anything besides "wake up" the ELSE message runs the first time. After that the result = "wake up" not longer works. So the timer continues to type "wake up" and there is no way to stop it. The player can now interact with objects in the room as if they are awake, but the timer can't be shut off, and there is no way for them to leave the room.


Oh..

EnableTimer (wake up)

Can you post the script for that timer?


Eh... I don't think I need the timer, sorry about that.

I would create a function that calls itself over and over until the correct input is entered, name it WakeFunction:

get input {
  if (result = "wake up") {
    msg ("You wake up.")
    DisableTimer (wake up)
    MoveObject (player, Sketchy Room)
  }
  else {
    msg ("bla bla msg?")
    WakeFunction
  }
}

Then, change what you've posted from your otherwise to this:

  otherwise {
    MakeObjectInvisible (subway vending water)
    msg ("description, fall asleep.")
    SetTimeout (1) {
      picture ("firstdreamsequence.gif")
      EnableTimer (wake up)
    }
    WakeFunction

J_J

Edit because I misunderstood you instructions. I will try this out. Thank you!


No problem!

I just create a function, then call the function from within itself if the player doesn't enter "wake up".

...and, actually, you should add a line to cover capital letters, so the function would be:

get input {
  result = LCase(result)
  if (result = "wake up") {
    msg ("You wake up.")
    DisableTimer (wake up)
    MoveObject (player, Sketchy Room)
  }
  else {
    msg ("bla bla msg?")
    WakeFunction
  }
}

J_J

I finally got to try it out, and it works perfectly. Thank you!


Log in to post a reply.

Support

Forums