FILE door.c - door object INHERITS /std/basic_lock.c see basic_lock.doc for further details SETUP FUNCTIONS set_here set_there set_master set_type QUERY FUNCTIONS query_direction query_in_long_short OTHER FUNCTIONS remove_door PROPERTIES room_desc check_mess DESCRIPTION The file /std/door.c contains code for making door objects. The door is added to the room with add_object(), either by having the door in a separate file or by having a "@make_door()" function in the room. A door must be present in both the rooms that should be connected. Two clones of the door is therefore needed, one in each room. That means you must have an add_object() in both rooms. In the door, the rooms and direction is set up with the set_here() and set_there() functions, and both are required for the room to work properly. The description of the door is seen in the long description of the room, and this description can be changed with the room_desc property. The door will also automatically install an exit in the room. If no name is set for the door it will name itself after the direction where it leads. It is always possible to refer to the door with the direction name. In the example below the door has the ids "big door", "east door" and "door" in the room "outside". If there are several doors in a room each must have an unique name, like "north iron door", "west iron door". If you want to have a lock on the door use the set_lock() function. Read more about that in basic_lock.doc. Don't use set_short() unless you want to have the door appear in the inventory of the room. EXAMPLE The file "irondoor.c": inherit "/std/door"; reset(arg) { ::reset(arg); if (arg) return; set_name("iron door"); set_here("east","outside"); set_there("west","treasury"); set_lock("abc123"); } In the reset() function in a room: add_object("irondoor"); Look in /examples/doors1 for more examples of doors. BUGS Don't name the door "door", give it a unique name instead. It already has the id "door" and it can bug if you have several doors in a room with set_name("door") or the same name. Destructing, updating, redoing or refreshing the rooms with the doors can make them behave strange. Best thing to do is clean away all doors and rooms with destruct and update. "redo" doesn't work because the old copy of the door isn't destructed. Both door clones must have exactly the same calls to set_here and set_there, otherwise they don't recognize each other and bugs. Build the doors as the /example rooms. ========================================================================== NAME set_here - set the exit for one of the rooms SYNTAX void set_here(string direction, string where, [string leave_message,] [string check_function]); DESCRIPTION Set the exit of the door in the direction 'direction' in the room 'where'. This is opposite of the add_exit semantics. The other optional arguments works exactly as add_exit in /std/basic_room, except that you must give check_function as an eval string, ie. "@check_south()". EXAMPLE set_here("east","outside"); will make an exit "east" in the room outside.c and the door in that room will have the alias "east door". NOTA BENE This function sets the master room for the door. Set this for the room which the player is most likely to enter first. Both set_here and set_there must be set up for a door. ========================================================================== NAME set_there - set the exit for the other of the rooms SYNTAX void set_there(string direction, string where, [string leave_message,] [string check_function]); DESCRIPTION Set the exit of the door in the direction 'direction' leading to the room 'where'. Otherwise it works exactly as add_exit in /std/basic_room, except that you must give check_function as an eval string, ie. "@check_south()". NOTA BENE Both set_here and set_there must be set up for a door. ========================================================================== NAME set_master - set master door SYNTAX void set_master(string master, string where) DESCRIPTION Sets which master door and room this door have. It makes this door a copy. By using this function it is possible to have different door files with different descriptions, locks and functions. EXAMPLE In file irondoor_front.c set_name("iron door"); set_long("This is a big iron door with strange symbols on it.\n"); set_here("east","outside"); set_there("west","treasury"); In file irondoor_backside.c set_name("black door"); set_long("This is a door painted in black.\n"); set_here("east","outside"); set_there("west","treasury"); set_master("iron door","outside"); ========================================================================== NAME set_type - set the type of the door SYNTAX void set_type(string t) DESCRIPTION If you want to set the type of the door to something else than "door", for example "hatch" or "gate", you can use this function. If you set the type to 0, the door only has the id set by set_name(), which can be useful in hidden doors. SEE ALSO /doc/std/hidden_door.doc ========================================================================== NAME query_direction SYNTAX string query_direction(); DESCRIPTION Returns the exit direction for the door. ========================================================================== NAME query_in_long_short SYNTAX string query_in_long_short(); DESCRIPTION Returns the short description of the door that shows in the long description of the room. ========================================================================== NAME remove_door SYNTAX string remove_door(); DESCRIPTION This function destructs the door and makes the exits open passages. ========================================================================== NAME room_desc - property DESCRIPTION This property can contain the description that appears in the long description of the room. If not set the room desc is "There is a $S $C to the $X". To have the door not show in the room desc set this property to 1. EXAMPLE add_property("room_desc","To the $X is a $S $C"); add_property("room_desc"); /* no desc in room */ SEE ALSO replace_vars in basic_lock.doc for usage of $S, $C, and $X ========================================================================== NAME check_mess - property DESCRIPTION This property can be set to a new message which is shown when a player tries to walk trough a closed door. Normally the message is "The $N is closed.\n". EXAMPLE add_property("check_mess","You walk into a closed door.\n"); SEE ALSO replace_vars in basic_lock.doc for usage of $N. ==========================================================================
Help topics available:
board.doc | box.doc | door.doc | hidden_door.doc | lib.doc |
remote | sequence.doc | simple_armour.doc | simple_container.doc | simple_weapon.doc |
You are guest number 161 since December 2019.
This file was last modified: June 2000.