Manual:DIL Manual/medium

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

medium

Variable (unitptr, read-only).

medium : unitptr

The unit used in the event that woke the program, when the event has one; otherwise null. What it is depends on the event:

  • SFB_DONE after give: the item or the coins given (target is the receiver). After put: the item put (target is the container). After get: the container it was taken from (target is the item). After a move: the room left (target is the room entered).
  • SFB_PRE with command(CMD_AUTO_DAMAGE): the weapon of the hit (randomt.zon's vorpal weapon waits for medium == self).
  • SFB_CMD, SFB_MSG from sendto(), SFB_TICK: null.
  • A send_done() or send_pre() from DIL passes its own medium.

Notes

  • Like activator and target it belongs to the current event: copy it into a variable right after the wait, and secure() the variable if it must outlast a wait or pause.
  • It can't be assigned.
  • Coins given arrive merged with the coins the receiver already holds; power is the amount given.

Example

dilbegin collector(wanted : string);
var
   item : unitptr;
   pc   : unitptr;
code
{
   :start:
   wait(SFB_DONE, command("give") and (target == self) and
                  (activator.type == UNIT_ST_PC));
   item := medium;
   pc := activator;
   if (item.symname != wanted)
   {
      act("$1n doesn't want $2n.", A_ALWAYS, self, item, pc, TO_VICT);
      goto start;
   }
   act("$1n thanks you for $2n.", A_ALWAYS, self, item, pc, TO_VICT);
   destroy(item);
   goto start;
}
dilend

An NPC (dilcopy collector@zone("gem@zone");) that takes one kind of item from players and destroys it, and says so when given anything else (the item then stays in its inventory).

See also