Locked Room won't unlock

Hi, I'm making a text adventure, and I have a lock mechanic set up, and the key incorporated, but I can't unlock the door. Here is the code I have for the door.
if (Got(Elegant Key)) {
UnlockExit (Vault door)
}


Where are you putting that code?

If you're putting it in the exit's script, note that exit scripts are only run if the door is already unlocked. You would need to have some way for the script to run before trying to use the exit. Maybe you could give the door an "unlock" verb, or give the key a "use" option that checks if they''re in the right room.

If you want to use the exit's script, then the script would look more like:

if (Got (Elegant Key)) {
  msg ("You unlock the door")
  game.pov.parent = this.to
  this.script = null
}
else {
  msg ("The door is locked and needs a key.")
}

(note that you wouldn't make the exit locked in this case, because the script handles the "It's locked" message itself)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums