Locked Doors

Anonynn
15 Jul 2015, 03:16
This isn't about just unlocking or locking a door in the traditional sense (and yes I've read the tutorial which isn't helpful in this case!) lol

Alright, so I have a locked door which can only be unlocked with a certain key. Here is the code for it...

if (Got(gh_silver_key)) {
UnlockExit (Upstairs Study Lock)
ClearScreen
msg ("<br/>You notice the silver lock on the door and remember the silver key you collected from the fireplace. Maybe.....it unlocks this? If so, why was it sitting in the fire like that? Hm.... Whatever the case, you pull out the silver key and stick it into the lock below the knob. To your surprise, it actually fits. \"Hm.\"<br/><br/>*Click*<br/><br/>You unlock it, and then discard the key --- you won't be needing it anymore. <br/><br/>After that, you carefully turn the knob and enter a Study. Afterward, you hear it lock behind you. Seems like you should hang onto the key until you're completely done with this area...otherwise you may get locked out. <br/>")
MoveObject (player, GH Upstairs Study)
}
else {
}


My problem is...I would like the door to remain permanently unlocked after the player uses the key, but all my attempts have failed (even making the key invisible after it's used). Am I just making this overly complicated?

HegemonKhan
15 Jul 2015, 03:56
We may have to see your entire game code... but let me see if this helps you at all (I'm not too familiar with this built-in stuff, and way back when, I was trying to learn quest for my first time too, I had, and still have lol, difficulty with opening~closing and locking~unlocking myself), so I'll see what I can do (too lazy at the moment to open up quest, going by my bad memory+understanding):

there's 4 states:

open~close
lock~unlock

and often two Elements as peoples' design:

the 'whatever named exit, example: exit_1' Exit
the 'example: door' Object

I believe that the 'lock~unlock' states are actually controlled by the built-in Boolean Attribute: 'locked'

door.locked = true ---> the door is locked
door.locked = false ---> the door is unlocked

exit_1.locked = true ---> the exit_1 is locked
exit_1.locked = false ---> the exit_1 is unlocked

-------

I'm not sure about 'open~close' states, I'll have to look that up again, for what controls~determines them.

------

I'm not familiar with this command~whatever: UnlockExit (Upstairs Study Lock)

any change to an Attribute's Value is permanent (until it is changed again, lol).

maybe it does unlock the exit, but you still got the 'door' Object that you didn't unlock. Do you have a 'door' Object too, or is just the Exit, your 'locked door' ???

or, maybe it does NOT unlock the exit, and so you can try adding this code line after it:

(there may be a problem with the spaces in your 'Upstairs Study Lock' too, causing the problem~s)

Upstairs Study Lock.locked = false

if (Got(gh_silver_key)) {
UnlockExit (Upstairs Study Lock)
Upstairs Study Lock.locked = false
ClearScreen
msg ("<br/>You notice the silver lock on the door and remember the silver key you collected from the fireplace. Maybe.....it unlocks this? If so, why was it sitting in the fire like that? Hm.... Whatever the case, you pull out the silver key and stick it into the lock below the knob. To your surprise, it actually fits. \"Hm.\"<br/><br/>*Click*<br/><br/>You unlock it, and then discard the key --- you won't be needing it anymore. <br/><br/>After that, you carefully turn the knob and enter a Study. Afterward, you hear it lock behind you. Seems like you should hang onto the key until you're completely done with this area...otherwise you may get locked out. <br/>")
MoveObject (player, GH Upstairs Study)
}
else {
}


-------------

ALSO:

remember that Exits are only one way, so to come back, there's a different Exit (for coming back) that you'll also have to unlock (if it too is locked).

Anonynn
15 Jul 2015, 06:03
Got that all fixed, thanks HK!

I was making it overly complicated.....Sorry about that.