Manual:DIL Manual/key

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:00, 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

key

Field (string, read/write; units: all, used on objects).

u.key : string

The key that locks and unlocks the unit, as "keyname@zone", set with key in the zone file. Empty when the unit has no key. The lock and unlock commands in basemove.zon look for a unit with this symbolic name in the player's inventory.

A room's exits have keys of their own: see exit_key.

Notes

  • Assigning a string replaces the key; assigning "" or null leaves the unit without one.
  • Whether the unit can be locked at all is in openflags (EX_OPEN_CLOSE, EX_LOCKED).
  • On null it fails.

Example

dilbegin integer has_key(pc : unitptr, item : unitptr);
var
   k : unitptr;
code
{
   if (item.key == "")
      return (FALSE);
   k := findsymbolic(pc, item.key, FIND_UNIT_IN_ME);
   return (k != null);
}
dilend

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

See also