Manual:DIL Manual/medium
Jump to navigation
Jump to search
Contents
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 (targetis the receiver). Afterput: the item put (targetis the container). Afterget: the container it was taken from (targetis the item). After a move: the room left (targetis the room entered). - SFB_PRE with
command(CMD_AUTO_DAMAGE): the weapon of the hit (randomt.zon's vorpal weapon waits formedium == 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;
poweris 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).