Class: room

Description:

Abilities: sensor, (container, containable, emitter, name)
Parent classes: holder, (object)

Rooms are objects which may contain creatures.

Usage:

#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
}

Functions:

All functions defined in class holder.

All functions defined in ability sensor.

void set_short(mixed s)
Shorthand for set_req_handler("/visual/short", s). See message types specific to classes for further explanation.

string query_short()
Shorthand for request_msg("/visual/short").

void set_long(mixed s)
Shorthand for set_req_handler("/visual/long", s). See message types specific to classes for further explanation.

string query_long()
Shorthand for request_msg("/visual/long").

string set_item_desc(string i, mixed s)
Shorthand for set_req_handler("/visual/item/" + i, s). See message types specific to classes for further explanation.

string query_item_desc(string i)
Shorthand for request_msg("/visual/item/" + i).

varargs void set_object(string ob, mixed m)
Place a thing or a creature in the room. The thing or creature is specified by aboslute filename ob. Argument m is optional: The inventory of a room is refreshed at every reset().

void set_objects(mixed *inv)
Instead of repeated 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:

mixed *query_objects()
Return the list that describes the inventory of the room. See 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
The name of the exit, such as north or cave.
room
The absolute filename of the room to which this exit is connected.
desc
Description of the exit. This is the description that is returned when message of type /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
Logical OR of the following flags:
  • 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
It is important that these flags are set up correctly, otherwise creatures and robots may get confused. Note that the most common type of exit is defined as EXIT_VANILLA and is equal to (EXIT_COMMON|EXIT_VISIBLE|EXIT_ENABLED). Also, see set_common_exit() below.
msg
When present, this arguments defines what messages should be emitted when a creature moves through the exit. It is a list of three elements ({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
If present, 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
If present, 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)
Change exit exit so that it is connected to room room.

void set_exit_desc(string exit, string desc)
Change the description of exit to desc.

void set_exit_type(string exit, int type)
Change the type of exit to type. See the description of type in function set_exit above for details.

void set_exit_visible(string exit, int v)
Change exit to visible if v is 1, and invisible if v is 0.

void set_exit_enabled(string exit, int e)
Enable or disable exit.

void delete_exit(string exit)
Delete exit from the list of exits.

mapping query_exits()
Return the mapping which describes exits. Each element in the mapping has the form 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)
Return the list ({ room, desc, type, msg, movep, move }) that specifies exit.

string query_exit_room(string exit)
Return the filename of the room that exit is connected to.

mixed *query_exit_desc(string exit)
Return the description of the exit.

int query_exit_type(string exit)
Return the type of the exit.

int query_exit_common(string exit)
Return 1 if exit is a common exit, i.e., one can pass through it with the go command.

int query_exit_changing(string exit)
Return 1 if the room that exit is connected to changes with time.

int query_exit_visible(string exit)
Return 1 if the exit is visible.

int query_exit_enabled(string exit)
Return 1 if the exit is enabled.

int exit_move_allowed(object ob, string exit)
Return 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)
Move object ob through exit. Note that no tests are made whether ob is actually allowed to move through exit.

Source code:

/class/room.c
/class/room/in/exit.c
/class/room/in/message.c
/class/room/in/move.c
/class/room/in/inventory.c
/include/room.h

See also:

Ability: containable
Ability: emitter