A
/ \ _ Play Now Nemesis on
| | | | _______ _ _ _______ _______ _ _______
| |\ | | | ____| | \ / | | ____| / ____| | | / ____|
/-------/-------------------------------------------------------------------,
O= Home <=XX| About News Pics Adventurers Wizards Download Connect >
\-------\-------------------------------------------------------------------'
| | \ | | |____ | | | | | |____ ___ \ \ | | ___ \ \
| | \_| |_______| |_| |_| |_______| |_______/ |_| |_______/
\ /
V
Documentation Area
Document Path: /doc/build/door2
door2 is a basic door implemented in the room. To use it, you have to
include door2.h AFTER room2.h. Then, call some functions in reset(0):
Mandatory:
- set_other_side(file);
Sets which room is on the other side of the door.
Then call these functions in one side:
- set_door_dir(str);
Sets the direction you have to walk to go through the door.
- set_door_id(array_or_string);
Sets all ids of the door (if it's a simple string, only one id
is possible). The first id is used as name.
And call this on the other side:
- import(); Gets all settings from the other side. The direction is the
opposite direction, which is calculated by
DIR_D->counter_direction(dir);
You can change all settings by calling the functions again.
Optional:
- set_door_long(str);
Sets the description if you look at the door. You will get this
description and "It is closed/open.".
- set_msg_level(arg);
Sets which messages are given to other people. There are three
defines in door2.h:
M_SOUND_IN_DARKNESS: Makes others "hear" an action
in darkness.
M_BUMP: Makes people "bump" into the
door if they try to go
"through" it.
M_TRANSLUCENT: Makes people on the other side
see who opens/closes/locks/
unlocks the door.
You can combine them with '+' or '|'.
- set_key(code);
Sets the key code for the door. If this is not set, it cannot
be locked. See also obj/key.c .
- set_check_darkness(arg);
Set if darkness should be checked for any open/close/lock/
unlock-action.
- set_close_locks(arg);
Sets if the door is automatically locked if someone closes it
and unlocked by opening. Therefor we have two defines,
CLOSE_LOCKS and OPEN_UNLOCKS. You can combine them with '+' or
'|', too.
Then you have to make an extra_init()-function and call door_init(). This will
do all needed add_action()s. You can also add some more possible verbs to go
through the door by calling add_action("go_door", verb); or, if the argument
is important, connect it to some other function. There you call go_door() if
everything is right about the argument.
These are functions which can be called from anywhere, or you can override
them:
- set_door_status(arg, silent);
Sets if the door is OPEN, CLOSED, or LOCKED. You can also call
it if nothing is set in the door, so in reset() before the
if (arg) return;
for example. If silent is 1, there will be NO messages to the
people in the rooms.
- door_closed();
Returns if the door is OPEN, CLOSED or LOCKED. You can also
just check "if (door_closed())", that means it is not open.
- door_very_short();
Returns a string like "a closed gate" or "an open door".
- door_short();
Returns a string like "an open door to the west" or "a closed
gate to the south". This sounds stupid if the door leads down
("an open door to the down"), so there use door_very_short().
These two functions can be used in an overwritten query_long()-
function.
- show_door();
Writes the long description of the door.
- is_master();
Returns if this side of the door is the master which keeps the
variables.
Additionally there are two functions you can override but which normally don't
do anything. The arguments passed to it are A_OPEN, A_CLOSE, A_LOCK, A_UNLOCK
and A_WALK. If the function returns 1, the player/monster is not able to open,
close, lock, unlock or go through the door.
- forbid_action1(action);
Is called before anything else is checked.
- forbid_action2(action);
Is called after everything else is checked.
Do not block wizards, better give a message like "Due to your wizardhood the
guard does not block you." and return 0. See also 'man wizardp'.
Now, here's an example:
#include <room2.h>
#include <door2.h>
#define KEYCODE "Example's key code"
#define KEYTYPE "small"
object key;
reset(arg) {
set_door_status(LOCKED);
if (!key || !present(key)) {
key = clone_object("obj/key");
key->set_code(KEYCODE);
key->set_type(KEYTYPE);
move_object(key);
}
if (arg) return;
// here do anything you normally do in a room, but don't set the door as exit.
set_other_side(HOMES+"example/behind_door");
set_door_dir("north");
set_door_id("door");
set_door_long("There's a "+KEYTYPE+" lock in it. ");
set_msg_level(M_DARKNESS_MSG + M_BUMP);
set_key(KEYCODE);
}
extra_init() {
door_init();
}
query_long() {
return ::query_long()+"There is "+door_short()+".\n";
}
For information about keys see also the note on the documentation board in the
inner guild or on https://nemesis.de/lpc/board/7/ .
See also:
This page was generated in LPC
Imprint / Impressum