Manual:DIL Manual/exit key
Jump to navigation
Jump to search
Contents
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
diris outside 0 toMAX_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.