Manual:DIL Manual/exit key

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:13, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

exit_key

Field (string, read/write; units: rooms).

room.exit_key[dir] : string

The key that locks and unlocks the room's exit in direction dir, as "keyname@zone" in lower case, set with key on the exit in the zone file. Empty when the exit has no key. The lock and unlock commands in basemove.zon look for a unit with this symbolic name in the player's inventory, and say "you can't seem to find a keyhole" when it is empty.

dir is a direction from vme.h: NORTH (0) to SOUTHWEST (9), MAX_EXIT being the last.

Notes

  • It fails when the unit is not a room, when dir is outside 0 to MAX_EXIT, and when the room has no exit that way (so it is not "" then). Test the exit with exit_to first.
  • Assigning a string replaces the key; assigning "" leaves the exit without one. No access level is needed.
  • Whether the exit can be locked at all is in exit_info (EX_OPEN_CLOSE, EX_LOCKED). An object's own key is the key field.

Example

dilbegin integer has_exit_key(pc : unitptr, room : unitptr, dir : integer);
var
   k : unitptr;
code
{
   if (not room.exit_to[dir])
      return (FALSE);
   if (room.exit_key[dir] == "")
      return (FALSE);
   k := findsymbolic(pc, room.exit_key[dir], FIND_UNIT_IN_ME);
   return (k != null);
}
dilend

Tells whether a player carries the key to a door, as lock and unlock do in basemove.zon.

See also