Locked door problem.

OurJud
28 Nov 2014, 17:29I know I'm probably going about this the wrong way by not using the 'unlock function', but in that the hut will remain unlocked once you've got inside, I decided to do it this way.
This is the script I have. If I type 'open door' or 'enter hut' I get the correct "door is locked" response, and if I type 'kick door' (or others) I successfully gain access. But if I follow the first command with the second, I get "I do not understand that command". Why?
Also, if anyone can produce the desired sequence in a more conventional way, feel free to say so.
This is the script I have. If I type 'open door' or 'enter hut' I get the correct "door is locked" response, and if I type 'kick door' (or others) I successfully gain access. But if I follow the first command with the second, I get "I do not understand that command". Why?
Also, if anyone can produce the desired sequence in a more conventional way, feel free to say so.
msg ("Looks like a security guard's hut.")
get input {
if (LCase(result)="kick door" or result="force door" or result="ram door" or result="barge door") {
msg ("<br/>The door gives up easily, opening with little more than a crack as the lock breaks through the rotting wood.<br/>")
MoveObject (player, hutinside)
}
if (LCase(result)="use gun" or result="shoot lock" or result="shoot lock with gun") {
msg ("<br/>You pull out your gun and fire a bullet at the lock area. Rotten wood splinters around you and the door swings open. You grin, \"Just like in the movies!\"<br/>")
MoveObject (player, hutinside)
}
if (LCase(result)="open" or result="open door" or result="enter" or result="enter hut" or result="go" or result="go hut" or result="go inside" or result="go inside hut") {
msg ("<br/>You try the door, but it's locked and rattles loosley in the frame.")
}
}

OurJud
28 Nov 2014, 19:13I've fashioned a workaround for this, but boy it seems elaborate.
Firstly I created another room called 'lockedhut'.
So when outside the original hut, any of the passive entry methods 'moves' the player to the 'lockedhut' room, which runs the message "You try the door, but it's locked and rattles loosely in the frame." After which I run the two input scripts for gaining access to the hut by force.
Arrgghh, but this doesn't work because if you try to be clever and try to gain access by force from the word go, you get a blank return as you haven't entered any of the passive entry commands.
Firstly I created another room called 'lockedhut'.
So when outside the original hut, any of the passive entry methods 'moves' the player to the 'lockedhut' room, which runs the message "You try the door, but it's locked and rattles loosely in the frame." After which I run the two input scripts for gaining access to the hut by force.
Arrgghh, but this doesn't work because if you try to be clever and try to gain access by force from the word go, you get a blank return as you haven't entered any of the passive entry commands.

OurJud
28 Nov 2014, 19:40Arrgghh! Why is this proving so difficult? What I want to do is not complicated!
If player types 'open door' >> print "The door is locked"
If player types 'kick door' >> print "The door flies open"
If player types 'shoot lock with gun' >> print "Wood splinters everywhere and the door flies open"
It works, just so long as you use any of the forced entry methods first. But if you use the passive method THEN try a forced method I get "I don't understand that command."
If player types 'open door' >> print "The door is locked"
If player types 'kick door' >> print "The door flies open"
If player types 'shoot lock with gun' >> print "Wood splinters everywhere and the door flies open"
It works, just so long as you use any of the forced entry methods first. But if you use the passive method THEN try a forced method I get "I don't understand that command."
Marzipan
28 Nov 2014, 20:11Why is it that you don't want to use unlock again? Wouldn't it make sense that the exit would stay open once the door has been smashed in?

jaynabonne
28 Nov 2014, 20:19For me, the complication is that you're using "get input" and parsing the input yourself rather than letting the normal Quest parser kick in and just using commands to make things happen as you wish.
That's why back to back commands don't work (I think). You're only calling "get input" once, so your processing only happens the first time. After that, the Quest parser takes over, and you have no commands defined for it to use. If you get rid of the "get input" and move things to commands, you can enter them all you wish.
That's why back to back commands don't work (I think). You're only calling "get input" once, so your processing only happens the first time. After that, the Quest parser takes over, and you have no commands defined for it to use. If you get rid of the "get input" and move things to commands, you can enter them all you wish.

OurJud
28 Nov 2014, 20:20I can't even remember now, my head's so fuzzled. I think it had something to do with me wanting the game to accept 'open door' as a command and not being able to do this with the locked/unlocked function.

OurJud
28 Nov 2014, 20:23jaynabonne wrote:If you get rid of the "get input" and move things to commands, you can enter them all you wish.
How do you mean, exactly?
I need to be able to set a series of commands that will do one of three things, not all do the same thing. I need a set of commands for passive entry, a set of commands for forced entry, and a set of commands for gun entry.
Marzipan
28 Nov 2014, 20:43I'm sure someone will pop up with some fancy trick, but if I were doing this I'd just keep it simple and have three separate commands. They all check first if the door is locked, then print the appropriate message and set it to unlock if the player is using the kicking or shooting method.
If the door has already been smashed, just have it print a different message to say so.
If the door has already been smashed, just have it print a different message to say so.

OurJud
28 Nov 2014, 20:51Marzipan wrote:I'm sure someone will pop up with some fancy trick, but if I were doing this I'd just keep it simple and have three separate commands. They all check first if the door is locked, then print the appropriate message and set it to unlock if the player is using the kicking or shooting method.
If the door has already been smashed, just have it print a different message to say so.
Man, this is EXACTLY what I need. I'm guessing this is what Jay meant too, but I wasn't clear.
It never occurred to be that you could add more than one set of commands for the same room.
I don't even have to bother with the locked scripts, either. The passive commands simply print a message saying the door is locked, the two forced methods print a message to say it's open then move the player to inside.
This is wonderful as I have another couple of places where I've used inputs and have discovered you can easily get locked in the room if you enter non defined commands. One you enter one, it won't understand anything after that.
Thanks, all.

jaynabonne
28 Nov 2014, 20:59That's exactly what I was going to say.
And you can have one command match each set of commands you want. For example, the pattern for one command could be:
kick door; force door; ram door; barge door
Then that one command will match any of those four inputs.

kick door; force door; ram door; barge door
Then that one command will match any of those four inputs.
Marzipan
28 Nov 2014, 21:05HURRAY I'M HELPING! 
Oh and make sure to let us smash door or break door, I know if I were playing those would be the first I'd try.

Oh and make sure to let us smash door or break door, I know if I were playing those would be the first I'd try.

OurJud
28 Nov 2014, 21:20Marzipan wrote:HURRAY I'M HELPING!
Oh and make sure to let us smash door or break door, I know if I were playing those would be the first I'd try.
Good call! I was trying to think of other feasible commands and neglected those two. Learning this one thing (that I can use multiple command sets for the same room) has relieved so many potential headaches and opened up so much!!
jaynabonne wrote:That's exactly what I was going to say.And you can have one command match each set of commands you want. For example, the pattern for one command could be:
kick door; force door; ram door; barge door
Then that one command will match any of those four inputs.
Yes, I have a whole heap of possibilities for each option


OurJud
28 Nov 2014, 22:06One tiny problem. Can you set up a command that will trigger a different action if the player inputs anything other than one of the set commands?
Basically, I need a command pattern that waits for the player to input anything other than the set of commands on the other command page, and then run a script which throws him outside. Can this be done?
This time the giving of a certain name is the problem.
I need one command which is the correct name - followed by a script that moves the player through to the next room.
But I need another command pattern for anything else the player may choose to input - followed by a script which throws him outside.
So, you're in the room and an NPC asks you for a name. Answer 'jackie' and you are allowed to pass through to the next room. Say anything else and you get thrown out.
In that I'm not using 'ifs' on my command pages, how would I achieve this?
Basically, I need a command pattern that waits for the player to input anything other than the set of commands on the other command page, and then run a script which throws him outside. Can this be done?
This time the giving of a certain name is the problem.
I need one command which is the correct name - followed by a script that moves the player through to the next room.
But I need another command pattern for anything else the player may choose to input - followed by a script which throws him outside.
So, you're in the room and an NPC asks you for a name. Answer 'jackie' and you are allowed to pass through to the next room. Say anything else and you get thrown out.
In that I'm not using 'ifs' on my command pages, how would I achieve this?

jaynabonne
28 Nov 2014, 22:35I hope this isn't too complicated... You could have a turnscript when in the room that has a "deadman" sort of variable. Basically, you have a flag somewhere (in the room, on the player) like "validcommand" which is initially set to false. If they enter a good command, it gets set to true. Else it will remain false when the turn script occurs.
The turn script runs after each command. If the "validcommand" flag has not been set to true by a good command, then it knows a good command wasn't entered, and the player gets booted. If there can be multiple good commands in sequence (else the boot), then have the turn script do like this:
Just set "validcommand" to false when entering the room and enable the turnscript. Disable the turnscript when they leave the room. And set validcommand to true if they do something right.
If at any point, they don't invoke a command that explicitly sets "validcommand", they get booted.
OR
If it's the case that answering the question moves them to the next room, then you might be able to just have the turn script boot them, period. if it's enabled when they come in the room and disabled when they leave, then if they're still in the room when the turn script triggers, they did bad.
(There might be an initial issue with not having the turn script boot them as soon as they come in the room. If you decide to go this way, I can help with that.)
The turn script runs after each command. If the "validcommand" flag has not been set to true by a good command, then it knows a good command wasn't entered, and the player gets booted. If there can be multiple good commands in sequence (else the boot), then have the turn script do like this:
if (player.validcommand) {
// player entered a valid command. Set to false for next command.
player.validcommand = false
// Now it will go back and get the next command in the room.
} else {
// Player didn't enter a valid command. Boot them.
msg("Get out!")
player.parent = outsideroom
}
Just set "validcommand" to false when entering the room and enable the turnscript. Disable the turnscript when they leave the room. And set validcommand to true if they do something right.
If at any point, they don't invoke a command that explicitly sets "validcommand", they get booted.
OR
If it's the case that answering the question moves them to the next room, then you might be able to just have the turn script boot them, period. if it's enabled when they come in the room and disabled when they leave, then if they're still in the room when the turn script triggers, they did bad.
(There might be an initial issue with not having the turn script boot them as soon as they come in the room. If you decide to go this way, I can help with that.)

OurJud
28 Nov 2014, 22:49I'm afraid that is a little too complicated, Jay. I've done nothing with variables yet, and only a little with flags.
The only two inputs that would stop you getting the boot are the correct answer to the question, and if you try to go north (direction of backroom) before answering (this results in you being grabbed and asked to answer the question (which is set on the 'room is locked' page).
Any input other than those two would see you thrown out.
The only two inputs that would stop you getting the boot are the correct answer to the question, and if you try to go north (direction of backroom) before answering (this results in you being grabbed and asked to answer the question (which is set on the 'room is locked' page).
Any input other than those two would see you thrown out.