Rooms are objects which may contain creatures.
#include <class.h> #include <room.h> inherit ROOM; void create() { room::create(); // initalizations from class object: // NOTE: do not set_name() for a room! set_alias(({"alias1", ..., "aliasN"})); // very optional // room description set_short(short_desc); // required (has alternative) set_long(OUTSIDE long_desc); // required (has alternative) set_long_in(long_desc); // required set_item_desc("item", description); // optional // inventory (including monsters) set_object("obj_file"); // optional set_object("obj_file", num_copies); // optional set_object("obj_file", test_func); // optional set_objects(list_of_objs); // ALTERNATIVE to set_object() // exits set_common_exit("exit_name", "room", "exit_desc"); // optional set_common_exit("exit_name", "room"); // optional set_exit(...); // optional }
void set_short(mixed s)
set_req_handler("/visual/short", s)
.
See message types specific to classes
for further explanation.
string query_short()
request_msg("/visual/short")
.
void set_long(mixed s)
set_req_handler("/visual/long", s)
.
See message types specific to classes
for further explanation.
string query_long()
request_msg("/visual/long")
.
string set_item_desc(string i, mixed s)
set_req_handler("/visual/item/" + i, s)
.
See message types specific to classes
for further explanation.
string query_item_desc(string i)
request_msg("/visual/item/" + i)
.
varargs void set_object(string ob, mixed m)
ob
. Argument
m
is optional:
ob
is
placed in the room
m
is a number, then m
copies of ob
are placed in the room
m
is a function, then the object is
placed in the room if m
returns non-zero.
This is useful for complicated tests.
reset()
.
void set_objects(mixed *inv)
set_object()
commands, the
inventory of a room can be set with set_objects
.
This overrides any previous set_object()
or
set_objects()
. Argument inv
is a
list, where each element is either:
ob
, which corresponds to
set_object(ob)
)
({ob, m})
, which corresponds to
set_object(ob, m)
.
mixed *query_objects()
set_objects
above for the description of the list.
varargs void set_exit(
string exit,
string room,
string desc,
int type,
mixed *msg,
function movep,
function move)
This function sets up an exit. Arguments exit
,
room
and type
are required. Other arguments
can be 0
or missing. Here is the description of each argument:
exit
north
or
cave
.
room
desc
/visual/exit/exit_name
is
requested. If desc
is 0
, then the
/visual/long
of the room that the exit is connected to
is returned instead.
type
EXIT_COMMON
- players pass through this exit
with the go
command (as opposed to a special
verb, such as enter cave
).
EXIT_CHANGING
-
exit connects to different rooms at different times
EXIT_VISIBLE
- exit is visible
EXIT_ENABLED
- exit is enabled
EXIT_VANILLA
and is equal
to (EXIT_COMMON|EXIT_VISIBLE|EXIT_ENABLED)
. Also,
see set_common_exit()
below.
msg
({msg_ob, msg_env, msg_dest})
, which are
messages emitted to the object, its environment, and its new
environment, respectively. Each of the msg_xxx
can
be a string, or a function. If it is a string, then $N
will be replaced by query_capname
of the object that is
being moved. If it is a function, the function must return a string,
or a composite message.
movep
movep
is a function of type int
movep(object ob, string exit)
. It should return 1
if object ob
is allowed to move through the exit,
and 0
otherwise.
move
move
is a function of type void
move(object ob, string exit)
. It is used for special effects
when an object moves through the exit. It is called after the object
has been successfully moved.
varargs void set_common_exit(
mixed exit,
string room,
string desc)
This is a simplified version of set_exit
, which
sets up a `common' or 'vanilla' exit. Argument exit
is
the name of the exit, room
is the absolute filename of
the room that the exit is connected to, and desc
is an
optional description of the exit. See set_exit
above for
detailed explanation of the arguments.
Alternatively, you can call the function with
set_common_exit(exits)
, where
exits
is a mapping of the form
(["exit1" :
"room1", "exit2" : "room2", ...])
.
void set_exit_room(string exit, string room)
exit
so that it is connected to room room
.
void set_exit_desc(string exit, string desc)
exit
to desc
.
void set_exit_type(string exit, int type)
exit
to type
.
See the description of type
in function
set_exit
above for details.
void set_exit_visible(string exit, int v)
exit
to visible if v
is
1
, and invisible if v
is 0
.
void set_exit_enabled(string exit, int e)
exit
.
void delete_exit(string exit)
exit
from the list of exits.
mapping query_exits()
exit : ({ room, desc, type, msg,
movep, move })
. You should use macros EXIT_XXXX
from room.h
for indexing the elements.
mixed *query_exit(string exit)
({ room, desc, type, msg,
movep, move })
that specifies exit
.
string query_exit_room(string exit)
exit
is connected to.
mixed *query_exit_desc(string exit)
exit
.
int query_exit_type(string exit)
exit
.
int query_exit_common(string exit)
1
if exit
is a common exit,
i.e., one can pass through it with the go
command.
int query_exit_changing(string exit)
1
if the room that exit
is
connected to changes with time.
int query_exit_visible(string exit)
1
if the exit
is visible.
int query_exit_enabled(string exit)
1
if the exit
is enabled.
int exit_move_allowed(object ob, string exit)
1
if object ob
is allowed to move
through exit
. Note that the move is not actually
performed.
int exit_move(object ob, string exit)
ob
through exit
.
Note that no tests are made whether ob
is actually
allowed to move through exit
.