Difference between revisions of "Manual:DIL Manual/send 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="bpsend_done"></span>
+
= send done() =
 +
'''Procedure.''' Tells the programs around that a command has been carried out.
  
−
'''Function:'''</i><!--ENDCODE-->
+
  send_done(cmd : string, activator : unitptr, medium : unitptr, target : unitptr,
−
  send_done( c : string, a :unitptr, m : unitptr, t :unitptr, p : integer, arg : string, o : unitptr);</i><!--ENDCODE-->
+
          power : integer, arg : string, other : unitptr, auto : integer)
  
−
<!--TERM--> '''c'''
+
Sends an <code>SFB_DONE</code> event, as the server does after a built-in command has succeeded. The programs around that wait for it, such as <code>wait(SFB_DONE, command("close") and (target == self))</code>, wake up and see <code>activator</code>, <code>medium</code>, <code>target</code>, <code>power</code> and <code>argument</code>. Commands written in DIL (basemove.zon, baseget.zon, baselook.zon) end with it, so that other scripts see them like built-in commands. It does nothing else: the command itself is not carried out.
−
<!--DEFINITION-->         the command string that is sending the message
 
−
<!--TERM--> '''a'''
 
−
<!--DEFINITION-->         the unitptr (activator) that activated the message
 
−
<!--TERM--> '''m'''
 
−
<!--DEFINITION-->         the unitptr (medium) that the Dil is acting through
 
−
<!--TERM--> '''t'''
 
−
<!--DEFINITION-->         the unitptr (target) the Dil is acting on
 
−
<!--TERM--> '''p'''
 
−
<!--DEFINITION-->         the power of the message
 
−
<!--TERM--> '''arg'''
 
−
<!--DEFINITION-->         the argument sent with the message
 
−
<!--TERM--> '''o'''
 
−
<!--DEFINITION-->        the unitptr (other) you also want the message to go to
 
  
 +
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| cmd || string || The command's name, as in <code>commands.def</code>: <code>"get"</code>, <code>"open"</code>, ...
 +
|-
 +
| activator || unitptr || Who did it; the event goes to the units around them.
 +
|-
 +
| medium || unitptr || What it was done with, or <code>null</code>.
 +
|-
 +
| target || unitptr || What it was done to, or <code>null</code>.
 +
|-
 +
| power || integer || A number for the receivers' <code>power</code>, e.g. an amount of money; usually 0.
 +
|-
 +
| arg || string || The receivers' <code>argument</code>.
 +
|-
 +
| other || unitptr || A unit elsewhere that should get the event too, or <code>null</code>.
 +
|-
 +
| auto || integer || <code>CMD_AUTO_NONE</code> (0) normally; <code>CMD_AUTO_ENTER</code> for an "entered" event (vme.h).
 +
|}
  
−
  This sends the 'SFB_DONE' message to any dils that are waiting for it in the
+
== Notes ==
−
  surrounding area and to the other pointer if not null. The following is just
+
* The event reaches the same units as a command the activator types: the activator, what it carries and wears, its room, everything in the room (also inside transparent units) and what the other characters there wear, and the room around when the activator is in a transparent unit. <code>other</code> gets it as well when it isn't among them.
−
  one example you can find many more in '''commands.zon'''
+
* With a null activator nothing is sent.
 +
* A name that isn't a command sends nothing and logs "send_done: DIL '...' attempted to send a non-existent command '...'" in the zone's log.
 +
* With <code>auto</code> set to <code>CMD_AUTO_ENTER</code>, <code>cmd</code> is ignored and the receivers see <code>command(CMD_AUTO_ENTER)</code>, as when a unit enters something. Any other <code>CMD_AUTO_</code> value logs "Unknown CMD_AUTO_ value" and sends nothing.
 +
* The program that calls <code>send_done</code> doesn't get the event itself.
 +
* A receiver that calls <code>block</code> keeps the event from the programs after it.
  
−
'''Example:'''
+
== Example ==
−
<i><!--CODE-->
+
<pre>
−
---~---~---~---~---~---~---~---~---
+
dilbegin close_item(item : unitptr);
−
 
+
code
−
dilbegin do_read (arg:string);
+
{
−
var
+
  if (isset(item.openflags, EX_CLOSED))
−
brdname:string;
+
  {
−
        i:integer;
+
      act("$2n is already closed.", A_ALWAYS, self, item, null, TO_CHAR);
−
        u:unitptr;
+
      return;
−
        x:extraptr;
+
  }
−
        ln:integer;
+
  act("You close $2n.", A_ALWAYS, self, item, null, TO_CHAR);
−
        temp:string;
+
  act("$1n closes $2n.", A_ALWAYS, self, item, null, TO_REST);
−
        templist:stringlist;
+
  set(item.openflags, EX_CLOSED);
−
        buff:string;
+
  send_done("close", self, null, item, 0, "", null, CMD_AUTO_NONE);
−
        f_name:string;
+
  return;
−
        act_str:string;
+
}
−
code
 
 
dilend
 
dilend
  
−
---~---~---~---~---~---~---~---~---
+
dilbegin chest_lid();
−
 
+
code
−
</i><!--ENDCODE-->
+
{
−
<span id="bpsend_done"></span>
+
  :start:
−
 
+
  wait(SFB_DONE, command("close") and (target == self));
−
'''Function:'''</i><!--ENDCODE-->
+
   act("The lid of $2n clicks shut.", A_ALWAYS, activator, self, null, TO_ALL);
−
send_done( c : string, a :unitptr, m : unitptr, t :unitptr, p : integer, arg : string, o : unitptr);</i><!--ENDCODE-->
+
  goto start;
−
 
+
}
−
<!--TERM-->  '''c'''
 
−
<!--DEFINITION-->        the command string that is sending the message
 
−
<!--TERM-->  '''a'''
 
−
<!--DEFINITION-->        the unitptr (activator) that activated the message
 
−
<!--TERM-->  '''m'''
 
−
<!--DEFINITION-->        the unitptr (medium) that the Dil is acting through
 
−
<!--TERM-->  '''t'''
 
−
<!--DEFINITION-->        the unitptr (target) the Dil is acting on
 
−
<!--TERM-->  '''p'''
 
−
<!--DEFINITION-->        the power of the message
 
−
<!--TERM-->  '''arg'''
 
−
<!--DEFINITION-->        the argument sent with the message
 
−
<!--TERM-->  '''o'''
 
−
<!--DEFINITION-->        the unitptr (other) you also want the message to go to
 
−
 
 
−
 
 
−
   This sends the 'SFB_DONE' message to any dils that are waiting for it in the
 
−
  surrounding area and to the other pointer if not null.  The following is just
 
−
  one example you can find many more in '''commands.zon'''
 
−
 
 
−
'''Example:'''
 
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
dilbegin do_read (arg:string);
 
−
var
 
−
brdname:string;
 
−
        i:integer;
 
−
        u:unitptr;
 
−
        x:extraptr;
 
−
        ln:integer;
 
−
        temp:string;
 
−
        templist:stringlist;
 
−
        buff:string;
 
−
        f_name:string;
 
−
        act_str:string;
 
−
code
 
 
dilend
 
dilend
 +
</pre>
 +
A command written in DIL closes a container and announces it; a program on the chest hears of it. The first is adapted from basemove.zon.
  
−
---~---~---~---~---~---~---~---~---
+
== See also ==
−
 
+
* [[Manual:DIL Manual/send pre()|send pre()]]
−
</i><!--ENDCODE-->
+
* [[Manual:DIL Manual/wait()|wait()]]
 +
* [[Manual:DIL Manual/command()|command()]]
 +
* [[Manual:DIL Manual/exec()|exec()]]
 +
* [[Manual:DIL Manual/SFB DONE|SFB_DONE]]

Latest revision as of 23:23, 14 November 2026

send done()

Procedure. Tells the programs around that a command has been carried out.

send_done(cmd : string, activator : unitptr, medium : unitptr, target : unitptr,
          power : integer, arg : string, other : unitptr, auto : integer)

Sends an SFB_DONE event, as the server does after a built-in command has succeeded. The programs around that wait for it, such as wait(SFB_DONE, command("close") and (target == self)), wake up and see activator, medium, target, power and argument. Commands written in DIL (basemove.zon, baseget.zon, baselook.zon) end with it, so that other scripts see them like built-in commands. It does nothing else: the command itself is not carried out.

Parameters

Name Type Meaning
cmd string The command's name, as in commands.def: "get", "open", ...
activator unitptr Who did it; the event goes to the units around them.
medium unitptr What it was done with, or null.
target unitptr What it was done to, or null.
power integer A number for the receivers' power, e.g. an amount of money; usually 0.
arg string The receivers' argument.
other unitptr A unit elsewhere that should get the event too, or null.
auto integer CMD_AUTO_NONE (0) normally; CMD_AUTO_ENTER for an "entered" event (vme.h).

Notes

  • The event reaches the same units as a command the activator types: the activator, what it carries and wears, its room, everything in the room (also inside transparent units) and what the other characters there wear, and the room around when the activator is in a transparent unit. other gets it as well when it isn't among them.
  • With a null activator nothing is sent.
  • A name that isn't a command sends nothing and logs "send_done: DIL '...' attempted to send a non-existent command '...'" in the zone's log.
  • With auto set to CMD_AUTO_ENTER, cmd is ignored and the receivers see command(CMD_AUTO_ENTER), as when a unit enters something. Any other CMD_AUTO_ value logs "Unknown CMD_AUTO_ value" and sends nothing.
  • The program that calls send_done doesn't get the event itself.
  • A receiver that calls block keeps the event from the programs after it.

Example

dilbegin close_item(item : unitptr);
code
{
   if (isset(item.openflags, EX_CLOSED))
   {
      act("$2n is already closed.", A_ALWAYS, self, item, null, TO_CHAR);
      return;
   }
   act("You close $2n.", A_ALWAYS, self, item, null, TO_CHAR);
   act("$1n closes $2n.", A_ALWAYS, self, item, null, TO_REST);
   set(item.openflags, EX_CLOSED);
   send_done("close", self, null, item, 0, "", null, CMD_AUTO_NONE);
   return;
}
dilend

dilbegin chest_lid();
code
{
   :start:
   wait(SFB_DONE, command("close") and (target == self));
   act("The lid of $2n clicks shut.", A_ALWAYS, activator, self, null, TO_ALL);
   goto start;
}
dilend

A command written in DIL closes a container and announces it; a program on the chest hears of it. The first is adapted from basemove.zon.

See also