Manual:DIL Manual/setroomexit()

From DikuMUD Wiki
Jump to navigation Jump to search

setroomexit()

Procedure. Points a room's exit in one direction at another room, making the exit if the room has none that way.

setroomexit(room : unitptr, dir : integer, toroom : unitptr)

If the room already has an exit in that direction, only its destination changes: the exit keeps its names, door flags, key and difficulty. If it has none, a new plain exit is made, with no door and no names. The exit goes one way only; to let players walk back, set the exit from the other room too.

The change lasts until the server reboots: rooms are not saved.

Parameters

Name Type Meaning
room unitptr The room the exit leads out of.
dir integer The direction, DIR_NORTH (0) to DIR_SOUTHWEST (9), from vme/include/vme.h.
toroom unitptr The room the exit leads to.

Notes

  • Every failure writes a line to the zone log and changes nothing: a null room, a direction outside 0 to 9, or a unit that is neither a room nor inside one. DIR_ENTER and DIR_EXIT (10 and 11) are not exits and are refused.
  • Pass only rooms. The procedure doesn't check that room and toroom really are rooms, only that they are in one: a character or an object there is taken as a room and corrupts the server's memory.
  • To close the exit again, pass a unitptr variable that holds null as toroom (vmc refuses a literal null: "Arg 3 of 'setroomexit' not an unitptr"). The exit stays, with no destination: room.exit_to[dir] is null and players who go that way are told they can't.
  • No access level is needed: any zone can change any room's exits.
  • Players see the new exit at once.

Example

dilbegin set_passage(from : string, to : string, isopen : integer);
var
   r1 : unitptr;
   r2 : unitptr;
   none : unitptr;
code
{
   r1 := findroom(from);
   r2 := findroom(to);
   if ((r1 == null) or (r2 == null))
      return;
   if (isopen)
   {
      setroomexit(r1, DIR_NORTH, r2);
      setroomexit(r2, DIR_SOUTH, r1);
   }
   else
   {
      setroomexit(r1, DIR_NORTH, none);
      setroomexit(r2, DIR_SOUTH, none);
   }
}
dilend

Opens a passage north and back south between two rooms, or closes it again (none is never set, so it is null).

See also