Run Script if Door is Locked?
The Bitter Baron
08 Nov 2016, 12:57Is there any kind of function I can access, or even code in manually without too much complexity, that allows a script to function if the player interacts with a locked door.
Below the "Print message when locked:" feature on exits there is an option for running a script instead; and so I made a system to support script activating when a player interacts with a locked door, only to find out that option was referring to using a script instead of porting the player using the exit; not using the script instead of giving the locked message. So now I have an entire area built around a concept I seemingly cannot activate in the way I hoped.

OurJud
08 Nov 2016, 14:27Your question isn't clear and I'm not really sure what your issue is. For a simple locked door script I would use flags.
if (GetBoolean(player, "gotKey")) {
msg ("The door opens.")
MoveObject (player, room)
}
else {
msg ("The door is locked.")
}
Of course this requires you to set a flag called gotKey on the player if you want the door to open.
The Pixie
08 Nov 2016, 14:42You can use that script, though it will be slightly more complicated.
if (this.locked) {
msg("However hard you try, you cannot open it")
}
else {
player.parent = this.to
}
The first line checks if it is locked. If it is, it prints the message, but you can replace that with your own script. If it is not locked, player.parent = this.to
will move the player to the exit's destination.
The Bitter Baron
08 Nov 2016, 23:34Where do I actually put either of those scripts in the game though, I looked in code view for the whole game itself and the script view for rooms but I cannot find any place to put them where they work.

OurJud
09 Nov 2016, 02:29Mine would go in the room with the locked door. Click on that room in the tree in the left pane, then click the 'room' tab from the list of tabs on the room (in the main pane on the right) and for 'Description' you would 'run script' and put it in there.
It sounds from your original post like you're trying to use the game's in-built 'locked exit' function. Rightly or wrongly I don't use these. For locked doors I just set flags and then check for them when necessary, as I've shown in my code above.
The Pixie
09 Nov 2016, 08:13Mine would go on the exit, the option for running a script that you mentioned.

OurJud
09 Nov 2016, 18:13Yes, so would mine, actually. I'm not using Quest at the moment so I'm badly out of date with what little knowledge I had. I find these days that I have to virtually learn this software all over again, every time I take a break from it.