Difference between revisions of "Manual:DIL Manual/send done()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| 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, | |
| − | send_done( | + | power : integer, arg : string, other : unitptr, auto : integer) |
| − | + | 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. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | == 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). | ||
| + | |} | ||
| − | + | == 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. <code>other</code> 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 <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 == | |
| − | + | <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 | 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 | 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()]] | |
| − | + | * [[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.
othergets 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
autoset toCMD_AUTO_ENTER,cmdis ignored and the receivers seecommand(CMD_AUTO_ENTER), as when a unit enters something. Any otherCMD_AUTO_value logs "Unknown CMD_AUTO_ value" and sends nothing. - The program that calls
send_donedoesn't get the event itself. - A receiver that calls
blockkeeps 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.