Difference between revisions of "Manual:DIL Manual/send done()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import of LLM wiki pages)
(checked against the compiler and the interpreter; example compiles)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
= 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)
  
−
<span id="bpsend_done"></span>
+
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.
  
−
'''Function:'''</i><!--ENDCODE-->
+
== Parameters ==
−
send_done( c : string, a :unitptr, m : unitptr, t :unitptr, p : integer, arg : string, o : unitptr);</i><!--ENDCODE-->
+
{| 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).
 +
|}
  
−
<!--TERM--> '''c'''
+
== Notes ==
−
<!--DEFINITION-->        the command string that is sending the message
+
* 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.
−
<!--TERM-->  '''a'''
+
* With a null activator nothing is sent.
−
<!--DEFINITION-->         the unitptr (activator) that activated the message
+
* 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.
−
<!--TERM--> '''m'''
+
* 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.
−
<!--DEFINITION-->         the unitptr (medium) that the Dil is acting through
+
* The program that calls <code>send_done</code> doesn't get the event itself.
−
<!--TERM--> '''t'''
+
* A receiver that calls <code>block</code> keeps the event from the programs after it.
−
<!--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
 
  
 +
== Example ==
 +
<pre>
 +
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
  
−
   This sends the 'SFB_DONE' message to any dils that are waiting for it in the
+
dilbegin chest_lid();
−
   surrounding area and to the other pointer if not null. The following is just
+
code
−
  one example you can find many more in '''commands.zon'''
+
{
 +
   :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
 +
</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.
  
−
'''Example:'''
+
== See also ==
−
<i><!--CODE-->
+
* [[Manual:DIL Manual/send pre()|send pre()]]
−
---~---~---~---~---~---~---~---~---
+
* [[Manual:DIL Manual/wait()|wait()]]
−
 
+
* [[Manual:DIL Manual/command()|command()]]
−
dilbegin do_read (arg:string);
+
* [[Manual:DIL Manual/exec()|exec()]]
−
var
+
* [[Manual:DIL Manual/SFB DONE|SFB_DONE]]
−
brdname:string;
 
−
        i:integer;
 
−
        u:unitptr;
 
−
        x:extraptr;
 
−
        ln:integer;
 
−
        temp:string;
 
−
        templist:stringlist;
 
−
        buff:string;
 
−
        f_name:string;
 
−
        act_str:string;
 
−
code
 
−
{
 
−
i:=atoi (arg);
 
−
if (i&lt;0)
 
−
        {
 
−
        exec ("look "+arg,self);
 
−
        goto read_quit;
 
−
        }
 
−
 
 
−
if (itoa (i)!=arg)
 
−
        {
 
−
        exec ("look "+arg,self);
 
−
        goto read_quit;
 
−
        }
 
−
 
 
−
u:=self.outside.inside;
 
−
while (u!=null)
 
−
        {
 
−
        if ((u.type==UNIT_ST_OBJ) and (u.objecttype==ITEM_BOARD))
 
−
                break;
 
−
        u:=u.next;
 
−
        }
 
−
 
 
−
if (u==null)
 
−
        {
 
−
        act ("You do not see that here.",A_ALWAYS,self,null,null,TO_CHAR);
 
−
        quit;
 
−
        }
 
−
 
 
−
                if (u.extra.["$BOARD_L_RES"].descr!="")
 
−
                {
 
−
                act_str:=u.extra.["$BOARD_L_RES"].descr(self,u);
 
−
                if (act_str!="")
 
−
                {
 
−
        act(act_str,
 
−
                        A_ALWAYS,self,null,null,TO_CHAR);
 
−
                quit;
 
−
                }
 
−
                }
 
−
 
 
−
brdname:=u.names.[length (u.names)-1];
 
−
i:=loadstr (brdname+".idx",temp);
 
−
if (i&lt;=0)
 
−
        {
 
−
        act ("But the board is empty!",
 
−
                A_ALWAYS,self,null,null,TO_CHAR);
 
−
        goto read_quit;
 
−
        }
 
−
 
 
−
templist:=split(temp,"&amp;x");
 
−
ln:=length (templist);
 
−
x:="$BOARD_MAX" in self.extra;
 
−
if ((atoi(arg)>atoi(x.descr)) or
 
−
(atoi(arg)>ln))
 
−
        {
 
−
        act("That message exists only within the boundaries of your mind.",
 
−
                A_ALWAYS,self,null,null,TO_CHAR);
 
−
        goto read_quit;
 
−
        }
 
−
 
 
−
i:=atoi(arg);
 
−
temp:=templist.[i-1];
 
−
f_name:=getword(temp);
 
−
i:=loadstr (brdname+"."+f_name,buff);
 
−
if (i==0)
 
−
        {
 
−
        sendtext("You have to let the poster finish the post before reading it.",self);
 
−
        quit;
 
−
        }
 
−
if (i&lt;1)
 
−
        {
 
−
        log("05: Error when loading board info.");
 
−
        act ("This board is not working report to an Administrator",
 
−
                A_ALWAYS,self,null,null,TO_CHAR);
 
−
                quit;
 
−
                }
 
−
 
 
−
templist:=split(f_name,".");
 
−
if (length(templist)&lt;2)
 
−
        act ("Message "+arg+":  "+temp,
 
−
                A_ALWAYS,self,null,null,TO_CHAR);
 
−
else
 
−
        act ("Message "+arg+":  Re:  "+temp,
 
−
                A_ALWAYS,self,null,null,TO_CHAR);
 
−
 
 
−
pagestring(buff,self);
 
−
 
 
−
:read_quit:
 
−
  send_done("read",self,null,u,0,arg,null);
 
−
quit;
 
−
}
 
−
dilend
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
</i><!--ENDCODE-->
 

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