Difference between revisions of "Manual:DIL Manual/SFB DONE"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = SFB_DONE = | |
| + | '''Constant''' (integer, vme.h: 0x0800). | ||
| − | SFB_DONE | + | wait(SFB_DONE, condition) |
| − | + | The "it has happened" event. It is sent after a command has succeeded: an item was given, taken or dropped, a character moved, a spell was cast. A program waiting with <code>SFB_DONE</code> learns about it after the fact, so <code>block</code> can't undo anything; use <code>SFB_CMD</code> or <code>SFB_PRE</code> to stop a command. | |
| − | |||
| − | |||
| − | + | == What the event holds == | |
| − | + | <code>activator</code>, <code>medium</code>, <code>target</code>, <code>power</code> and <code>argument</code> are set by the command that sends it; <code>command("name")</code> tells which command it was. Some of them: | |
| − | |||
| − | + | {| class="wikitable" | |
| − | + | ! Command !! activator !! medium !! target !! power | |
| + | |- | ||
| + | | command("give") || the giver || the item, or the money || the one who got it || the amount, for money | ||
| + | |- | ||
| + | | command("get") || the taker || where it was taken from (null from the floor) || the item || 0 | ||
| + | |- | ||
| + | | command("drop") || the one dropping || null || the item || 0 | ||
| + | |- | ||
| + | | command("north") etc. || the one moving || the room being left || the room being entered || the direction | ||
| + | |- | ||
| + | | command(CMD_AUTO_ENTER) || the one moving || the unit that moved (the character, or what carried it) || the room that was left || the direction | ||
| + | |- | ||
| + | | command("cast") || the caster || the caster, or the scroll, wand or staff || the target || the spell number | ||
| + | |} | ||
| − | + | == Notes == | |
| − | + | * give, get and drop are commands written in DIL (baseget.zon) that send the event with <code>send_done()</code>; any DIL command can do the same. Check the <code>send_done()</code> call in the command's source when you need to know what a command puts in each value. | |
| − | + | * The event reaches the activator's surroundings, as a command does (see [[Manual:DIL Manual/SFB CMD|SFB_CMD]]), and also <code>target</code> or the unit named in <code>send_done()</code> when it is somewhere else. | |
| + | * The direction event is sent while the mover is still in the old room; <code>CMD_AUTO_ENTER</code> comes after it has arrived, and is heard in the new room. | ||
| + | * When a player enters the game (<code>CMD_AUTO_PLAY</code>) or leaves it (<code>CMD_AUTO_LEAVE</code>), an <code>SFB_DONE</code> goes to the room <code>void@basis</code>. | ||
| + | * A program doesn't get the events of its own unit unless it is declared <code>aware</code>. | ||
| + | * Given money is merged with the coins the receiver already has, so <code>medium</code> may be the whole pile; <code>power</code> is the amount given. | ||
| − | command( | + | == Example == |
| + | <pre> | ||
| + | dilbegin thanks(); | ||
| + | var | ||
| + | pc : unitptr; | ||
| + | code | ||
| + | { | ||
| + | :start: | ||
| + | wait(SFB_DONE, command("give") and (target == self)); | ||
| − | + | pc := activator; | |
| − | + | if (medium.type != UNIT_ST_OBJ) | |
| − | + | goto start; | |
| − | |||
| − | |||
| − | + | exec("say Thank you for " + medium.name + ", " + pc.name + ".", self); | |
| − | + | goto start; | |
| − | + | } | |
| − | + | dilend | |
| + | </pre> | ||
| + | A monster that thanks whoever gives it something. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/send done()|send_done()]] | |
| − | + | * [[Manual:DIL Manual/wait()|wait()]] | |
| − | + | * [[Manual:DIL Manual/medium|medium]] | |
| − | + | * [[Manual:DIL Manual/target|target]] | |
| − | + | * [[Manual:DIL Manual/power|power]] | |
| − | + | * [[Manual:DIL Manual/SFB CMD|SFB_CMD]] | |
| − | + | * [[Manual:DIL Manual/SFB PRE|SFB_PRE]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:24, 14 November 2026
SFB_DONE
Constant (integer, vme.h: 0x0800).
wait(SFB_DONE, condition)
The "it has happened" event. It is sent after a command has succeeded: an item was given, taken or dropped, a character moved, a spell was cast. A program waiting with SFB_DONE learns about it after the fact, so block can't undo anything; use SFB_CMD or SFB_PRE to stop a command.
What the event holds
activator, medium, target, power and argument are set by the command that sends it; command("name") tells which command it was. Some of them:
| Command | activator | medium | target | power |
|---|---|---|---|---|
| command("give") | the giver | the item, or the money | the one who got it | the amount, for money |
| command("get") | the taker | where it was taken from (null from the floor) | the item | 0 |
| command("drop") | the one dropping | null | the item | 0 |
| command("north") etc. | the one moving | the room being left | the room being entered | the direction |
| command(CMD_AUTO_ENTER) | the one moving | the unit that moved (the character, or what carried it) | the room that was left | the direction |
| command("cast") | the caster | the caster, or the scroll, wand or staff | the target | the spell number |
Notes
- give, get and drop are commands written in DIL (baseget.zon) that send the event with
send_done(); any DIL command can do the same. Check thesend_done()call in the command's source when you need to know what a command puts in each value. - The event reaches the activator's surroundings, as a command does (see SFB_CMD), and also
targetor the unit named insend_done()when it is somewhere else. - The direction event is sent while the mover is still in the old room;
CMD_AUTO_ENTERcomes after it has arrived, and is heard in the new room. - When a player enters the game (
CMD_AUTO_PLAY) or leaves it (CMD_AUTO_LEAVE), anSFB_DONEgoes to the roomvoid@basis. - A program doesn't get the events of its own unit unless it is declared
aware. - Given money is merged with the coins the receiver already has, so
mediummay be the whole pile;poweris the amount given.
Example
dilbegin thanks();
var
pc : unitptr;
code
{
:start:
wait(SFB_DONE, command("give") and (target == self));
pc := activator;
if (medium.type != UNIT_ST_OBJ)
goto start;
exec("say Thank you for " + medium.name + ", " + pc.name + ".", self);
goto start;
}
dilend
A monster that thanks whoever gives it something.