Difference between revisions of "Manual:DIL Manual/target"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = target = | ||
| + | '''Variable''' (unitptr, read-only). | ||
| + | target : unitptr | ||
| − | < | + | The unit an action in the event was aimed at, when the event has one; otherwise null: |
| − | + | * SFB_DONE after <code>give</code>: the receiver. After <code>get</code> and <code>drop</code>: the item. After <code>put</code>: the container. After a move: the room entered. | |
| − | + | * SFB_PRE with <code>command(CMD_AUTO_DAMAGE)</code>: the victim of the hit. SFB_PRE for a spell: the spell's target. | |
| − | + | * SFB_CMD, SFB_MSG from sendto(), SFB_TICK: null. | |
| − | + | * A send_done() or send_pre() from DIL passes its own target. | |
| − | |||
| − | + | == Notes == | |
| + | * The usual give handler waits for <code>command("give") and (target == self)</code>; <code>medium</code> is then the item, already in <code>self</code>'s inventory. | ||
| + | * 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. | ||
| + | * <code>target</code> is a reserved word, so no variable can be called <code>target</code>; use <code>tgt</code> or <code>vict</code>. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | dilbegin altar_watch(); | ||
| + | code | ||
| + | { | ||
| + | :start: | ||
| + | wait(SFB_DONE, command("get") and (medium == self)); | ||
| + | act("The altar glows as $1n takes $2n from it.", | ||
| + | A_SOMEONE, activator, target, null, TO_ROOM); | ||
| + | act("The altar glows as you take $2n from it.", | ||
| + | A_SOMEONE, activator, target, null, TO_CHAR); | ||
| + | goto start; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | An altar (an object with this program) that glows when someone takes something from it: in a <code>get</code>, <code>medium</code> is the container and <code>target</code> the item taken. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/activator|activator]] | ||
| + | * [[Manual:DIL Manual/medium|medium]] | ||
| + | * [[Manual:DIL Manual/send done()|send done()]] | ||
| + | * [[Manual:DIL Manual/SFB DONE|SFB DONE]] | ||
| + | * [[Manual:DIL Manual/SFB PRE|SFB PRE]] | ||
Latest revision as of 23:18, 14 November 2026
Contents
target
Variable (unitptr, read-only).
target : unitptr
The unit an action in the event was aimed at, when the event has one; otherwise null:
- SFB_DONE after
give: the receiver. Aftergetanddrop: the item. Afterput: the container. After a move: the room entered. - SFB_PRE with
command(CMD_AUTO_DAMAGE): the victim of the hit. SFB_PRE for a spell: the spell's target. - SFB_CMD, SFB_MSG from sendto(), SFB_TICK: null.
- A send_done() or send_pre() from DIL passes its own target.
Notes
- The usual give handler waits for
command("give") and (target == self);mediumis then the item, already inself's inventory. - 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.
targetis a reserved word, so no variable can be calledtarget; usetgtorvict.
Example
dilbegin altar_watch();
code
{
:start:
wait(SFB_DONE, command("get") and (medium == self));
act("The altar glows as $1n takes $2n from it.",
A_SOMEONE, activator, target, null, TO_ROOM);
act("The altar glows as you take $2n from it.",
A_SOMEONE, activator, target, null, TO_CHAR);
goto start;
}
dilend
An altar (an object with this program) that glows when someone takes something from it: in a get, medium is the container and target the item taken.