I need an exit to appear when I open a door

First I'm trying to find a way for the same door to appear in both rooms so the player can walk from hall to kitchen and from kitchen to hall. I know there is something about this in the Quest help file but there is not much information bout it. The door needs to appear as an object in the room or as part of the room text description.

Is there a way to have an new exit appear when I open the door? At the moment after the door is opened the player can go to another room by typing "GO DOOR" which is a command but not all players would know to do, so I thought an exit appearing would be better when the player has opened the door.

The third problem is when there is more than one door in the room so if the player typed "open door" then Quest needs to know which door, the only solution I can think of is for the player to type "OPEN SOUTH DOOR" or "OPEN EAST DOOR" but then would the player know that you need to type this in.


(As you mentioned having multiple doors, for code samples in this post I'm assuming that the doors are named something like door1, door2, door3 and so on, while the exits are named exit125, exit126, and so on. You can change them to whatever your doors/exits are actually named)

I'd normally suggest making each door a container. This gives you the "open" / "close" functionality, and also allows you to add "lock" / "unlock" with just a couple of clicks. Doors aren't really containers, so you'd probably want to set the addscript so that it displays a message rather than allowing the player to put something in the door. (The script titled Script to run when trying to add an object on the Container tab). You could either display a simple "You can't do that" message, or move the object to the other side of the door (so "put fish in door" is basically throwing an object through the door)

If there's a door in the lounge which leads to the kitchen, and a door in the kitchen leading to the lounge, you'd want to make sure they're open at the same time. There are two scripts onopen and onclose ("After opening" and "After closing" in the GUI), which you would set to:

door2.isopen = this.isopen

(using the name of the door on the other side, so that opening or closing the door opens or closes both sides of it, adding to the impression that they're a single object visible from both rooms.

First I'm trying to find a way for the same door to appear in both rooms so the player can walk from hall to kitchen and from kitchen to hall. I know there is something about this in the Quest help file but there is not much information bout it. The door needs to appear as an object in the room or as part of the room text description.

I'd suggest creating the exits to start with, and not allowing the player to go through it until the door is open. An exit can have a script which runs instead of moving the player to another room. You'd set it to something like:

if (GetBoolean (door1, "isopen")) {
  MovePlayer (this.to)
}
else {
  msg ("You can't go that way while the {object:door1:door} is closed.")
}

Is there a way to have an new exit appear when I open the door?

Yes. Theoretically you can create an exit:

create exit ("north door", hall, kitchen, "northdirection")

or you could have the exit already there but invisible, and set it to visible when you want the player to access it.

With the method I described above (a script on the exit), the exit will show on the compass or in the "You can go:" line, but attempting to go through it will display a message saying the door is closed. If you make the exit invisible, it won't be shown to the player until the door is opened, and attempting "go north" prematurely would just say "You can't go that way." with no explanation. Choosing between the two is a matter of personal taste.

The third problem is when there is more than one door in the room so if the player typed "open door" then Quest needs to know which door, the only solution I can think of is for the player to type "OPEN SOUTH DOOR" or "OPEN EAST DOOR" but then would the player know that you need to type this in.

If you have the exits be directional, then the player can use them in the same way they would every other exit (using the compass, or clicking the links in the room description). If you really want "go door" to work, you could give the exit an alias like "north door", while having it still inherit northdirection, so that the commands "go door", "go north", and "n" are all equivalent. In this case, typing "go door" would be ambiguous in a room with multiple doors, so it would pop up a menu asking if the player meant north door or east door.

One thing I've played with before is changing a door's alias once it is opened. On the "After opening" script, it would be something like:

doorr4.isopen = true
if (this.alias = "north door") {
  msg ("The door creaks open to reveal a grimy domestic kitchen beyond.")
  this.alias = "kitchen door"
  this.alt = Split ("north door")
  exit199.alias = "kitchen door"
  exit199.alt = Split ("north door;north;n")
}

This means that once the door is open, it becomes "door to kitchen" in the Places/Objects pane and room descriptions (if you're using them), and the player could do "close kitchen door" or similar. They can also enter "north", "go door", "go north door", or "go kitchen" as they wish.


Hi mrangel.

I like your suggestions thanks.
The "have the exit already there but invisible, and set it to visible when you want the player to access it" makes it easy for the programmer writing the script but like you said it does not provide a reason why the player can't move in a certain direction.

The other ideas I thought of but are a bit lazy.
If the player goes north or types 'go door' then the player could get a message "you open the door and enter into another room" after moving the player to another room.
Also opening the door could automatically move the player to another room with the same above message.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums