I offered one of my usual hacks today, to a poster who was asking how to gain access to a room by entering a specific command.
As always, I knew in the back of my mind that I wasn't doing it the 'correct' way, and that my solution didn't cover all possibilities.
This was my method:
msg ("There is a guard here. He asks you for the password. The locked door is north. East is an unguarded exit.")
get input {
if (result="e") {
MoveObject (player, room 3)
}
else if (result="1234") {
UnlockExit (locked)
msg ("The guard steps aside to allow you access.")
}
else {
msg ("\"Wrong password.\"")
ShowRoomDescription
}
Which works, but only to a certain extent.
The problem with this is that the player really only has the option to enter the password, and any other command will return "Wrong password." which is why I added the extra if for the unlocked exit to the east.
So, out of interest, and just because it will be a handy script to store, how would this be done correctly?
Ideally, the player would have the freedom to enter any other command (and receive either a positive response or an unresolved one as with any other room), but how would this be achieved?