Combination lock?

Kealran

Hi,

I'm fairly new to this software and I can't seem to find an answer on how to do that a combination lock. I'm designing a simple escape room type of game for my students to play in.

I can make a lock and a key to open it, but I'm not sure which script to use in order to make a lock that requires the player to type in a combination (ex: 753).

Thank you for any help you can give.


DarkLizerd

When the player looks at the keypad...
msg("It looks like you need to enter a number.")
get input {
keyed=ToInt(result)
if(keyed=doorcode) {
msg("The green light comes on and the door opens.")
} else {
msg("The red light comes on and the keypad emits a bad sounding beep.")
}


hegemonkhan

there's only two ways of getting typed-in input:

  1. the 'get input' Script/Function: http://docs.textadventures.co.uk/quest/scripts/get_input.html
  2. the 'Command' Element: http://docs.textadventures.co.uk/quest/elements/command.html

Kealran

oh, nice. Thanks I was putting in the get input but not the keyed part. Sweet!


hegemonkhan

you can just use the built-in 'result' Variable VARIABLE too (sometimes it's good to create another Variable Variable or usually you need an Attribute VARIABLE, and sometimes it's better to just use the 'result' Variable VARIABLE).

'result' is a built-in Variable VARIABLE ('get input' and 'show menu/ShowMenu' and 'ask/Ask' all store your input automatically/hidden-from-you into the built-in 'result' Variable VARIABLE)

your/custom 'keyed' Variable VARIABLE is no different than the built-in 'result' Variable VARIABLE (so why re-store your input into another Variable VARIABLE: 'keyed', when your input is already stored in the Variable VARIABLE: 'result', ??? Unless you've got a reason for needing to store it into your own/custom Variable VARIABLE, just use the 'result' Variable VARIABLE)

// When the player looks at the keypad:

msg ("It looks like you need to enter a number.")
get input {
  if (ToInt (result) = NAME_OF_OBJECT.NAME_OF_DOOR_CODE_INTEGER_ATTRIBUTE) {
    msg("The green light comes on and the door opens.")
  } else {
    msg("The red light comes on and the keypad emits a bad sounding beep.")
  }
}

// or:

msg ("It looks like you need to enter a number.")
get input {
  if (result = NAME_OF_OBJECT.NAME_OF_DOOR_CODE_STRING_ATTRIBUTE) {
    msg("The green light comes on and the door opens.")
  } else {
    msg("The red light comes on and the keypad emits a bad sounding beep.")
  }
}

Log in to post a reply.

Support

Forums