Difference between revisions of "Manual:DIL Manual/SFB DONE"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="sfbdone"></span>
+
= SFB_DONE =
 +
'''Constant''' (integer, vme.h: 0x0800).
  
−
  SFB_DONE           'Command has now been executed' message
+
  wait(SFB_DONE, condition)
  
−
  When this flag is set, the program gets activated by all successful commands
+
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.
−
  issued by PC's or NPC's. The 'activator', 'medium' and 'target' special
 
−
  values are used as follows:
 
  
−
      'activator'... The PC / NPC which executed the command
+
== What the event holds ==
−
      'medium'...... The unit which is operated upon.
+
<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:
−
      'target'...... The target of the operation.
 
  
−
  For example, assume the player John gives a garlic to Mary the Lumberjack
+
{| class="wikitable"
−
  wife. The following values are set:
+
! 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
 +
|}
  
−
      activator == John (unitptr)
+
== Notes ==
−
      medium    == Mushroom (unitptr)
+
* 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.
−
      target    == Mary (unitptr)
+
* 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(CMD_GIVE) will evaluate to true.
+
== Example ==
 +
<pre>
 +
dilbegin thanks();
 +
var
 +
  pc : unitptr;
 +
code
 +
{
 +
  :start:
 +
   wait(SFB_DONE, command("give") and (target == self));
  
−
   You thus know that Mary has in fact received the mushroom. It is NOT possible
+
   pc := activator;
−
   to block (using the 'block' command) these commands since they have already
+
   if (medium.type != UNIT_ST_OBJ)
−
  been executed at the time of notification.  In a 'get' command, medium would
+
      goto start;
−
  be a unitptr to where the unit was taken from, and target would be the object
 
−
  which was taken.
 
  
−
   See the file commands.txt for a description of how the arguments are set for
+
   exec("say Thank you for " + medium.name + ", " + pc.name + ".", self);
−
  each command. If you can not find a command in there, just ask to get it
+
   goto start;
−
   implemented. Especially you should pay attention to the non-obvious SFB_DONE
+
}
−
  command(CMD_AUTO_ENTER).
+
dilend
 +
</pre>
 +
A monster that thanks whoever gives it something.
  
−
---~---~---~---~---~---~---~---~---
+
== See also ==
−
<span id="sfbdone"></span>
+
* [[Manual:DIL Manual/send done()|send_done()]]
−
 
+
* [[Manual:DIL Manual/wait()|wait()]]
−
SFB_DONE          'Command has now been executed' message
+
* [[Manual:DIL Manual/medium|medium]]
−
 
+
* [[Manual:DIL Manual/target|target]]
−
  When this flag is set, the program gets activated by all successful commands
+
* [[Manual:DIL Manual/power|power]]
−
  issued by PC's or NPC's. The 'activator', 'medium' and 'target' special
+
* [[Manual:DIL Manual/SFB CMD|SFB_CMD]]
−
  values are used as follows:
+
* [[Manual:DIL Manual/SFB PRE|SFB_PRE]]
−
 
 
−
      'activator'... The PC / NPC which executed the command
 
−
      'medium'...... The unit which is operated upon.
 
−
      'target'...... The target of the operation.
 
−
 
 
−
  For example, assume the player John gives a garlic to Mary the Lumberjack
 
−
  wife. The following values are set:
 
−
 
 
−
      activator == John (unitptr)
 
−
      medium    == Mushroom (unitptr)
 
−
      target    == Mary (unitptr)
 
−
 
 
−
  command(CMD_GIVE) will evaluate to true.
 
−
 
 
−
  You thus know that Mary has in fact received the mushroom. It is NOT possible
 
−
  to block (using the 'block' command) these commands since they have already
 
−
  been executed at the time of notification.  In a 'get' command, medium would
 
−
  be a unitptr to where the unit was taken from, and target would be the object
 
−
  which was taken.
 
−
 
 
−
  See the file commands.txt for a description of how the arguments are set for
 
−
  each command. If you can not find a command in there, just ask to get it
 
−
  implemented. Especially you should pay attention to the non-obvious SFB_DONE
 
−
  command(CMD_AUTO_ENTER).
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 

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 the send_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 target or the unit named in send_done() when it is somewhere else.
  • The direction event is sent while the mover is still in the old room; CMD_AUTO_ENTER comes 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), an SFB_DONE goes to the room void@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 medium may be the whole pile; power is 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.

See also