Doors doors

Just an inquisition here...

How do you all handle doors that lead from one room to another that are initially locked?

Questions I always consider:

  1. It's a door, so it logically has to be visible in both rooms, right?
  2. Must it be a 'closed container' so that it can be opened and closed and be locked?
  3. Unlocking the door and opening it must also unlock (or make visible) an exit?
  4. After unlocking the door, can you 'go e' for example and automatically go through the door or should I handle the open door/close door scripts so it doesn't appear so obviously un-door-like?

Should I be at all concerned with these dumb doors and locked exits at all?!

It just seems like so much code and situation to consider for simply having a door.

On the features tab, you will find a check for containers, but instead of then choosing 'closed container', choose the one that says 'openable/closable'. The tendency with containers, whether open or closed, is that someone could enter: 'put hat in door', and if you've coded it wrong, that is where the hat might end up.
Logically, the door should be in both connecting rooms, so I label my doors 'door1a' and door1b', so I know they join.
You can lock the exit to the room, and then unlock the exit or make the exit visible, you'll find these at the bottom of the 'openable/closable' option.

  1. Yes. Suppose you have a door between the lounge and hall. Create the door object in the hall.
    Go to the Features of the game object, tick the "Advanced script" box, then go to the Advanced script tab. In the bottom script, add code:
if (player.parent = lounge) {
  list add (items, door)

Now the door is in both rooms!

  1. Make it openable/closeable (same tab). You can set it to be lockable, and suddenly scripts will get added.

  2. Two exits. Makes those scripts editable, and do it in there, after the call to OpenObject.

How you handle it depends on what you want the player to do. An entirely different approach would be to run a the script on the edit that ckecks if the player has the key, and only moves the player if she has.

Also, and this is easy to miss sometimes, as I've done it myself.
If you open 'door1a' or unlock 'door1a' then 'door1b' is also opened and unlocked.
So many times when checking my scripting, I've unlocked and opened the door, gone through into the next room to find I can't go back because the doors locked.

@ Doctor Agon:

yep, to be safe, any action (open/close/lock/unlock/etc) to either door, should be done (coded) to the other door, as well. Unless you specifically want a one-way door for your game design (think of original zelda game, with one-way doors for its dungeons).

@ XanMag:

It always takes me forever (and over and over again too) to figure out how to get all the built-in coding for handling doors figured out and working correctly...

so, I'd just bookmark/favorite Pixie's post above, and use it, whenever I work on handling doors... laughs

If the door is a closed container, then remember to add a script for when the player tries to put something in it :p It would seem a little surreal if you can open the door and then put something in it.
Maybe a quick script so that "Put object in door" transfers the object to the room on the other side when it's open.

Chuckles... having a door that is a container in real life would be cool... no one would ever think that the door has a secret compartment to hide stuff within it, hehe :D

you could have this intentionally within you game too: a door that is a container, hiding some thing within its secret compartment, as a puzzle (a very hard puzzle, as who would think that there's something hidden within the door, hehe).

you could have this intentionally within you game too

I already have this in a game, you guys!

...AND you can TAKE the door!

It works like a normal door, too, of course. Until you've moved it once...

...and the room it leads to is just a worthless, empty room.


(Who will figure that out???)

Log in to post a reply.