Manual:DIL Manual/send done()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:23, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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