Difference between revisions of "Manual:DIL Manual/send pre()"
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = send_pre() = | ||
| + | '''Function''' (integer). Asks the programs around a character whether a command may go ahead. | ||
| + | send_pre(cmd : string, who : unitptr, med : unitptr, tgt : unitptr, pwr : integer, | ||
| + | arg : string, other : unitptr) | ||
| − | < | + | When a DIL does something on a character's behalf that a command would normally do (moving, |
| − | + | fleeing), other programs expect to hear about it first: a guard that blocks an exit waits with | |
| + | <code>wait(SFB_PRE, command("north") ...)</code>. send_pre() sends that <code>SFB_PRE</code> | ||
| + | event as if <code>who</code> had typed the command, to the programs the command itself would | ||
| + | reach: those in the room, on the room, and on what <code>who</code> carries. Each can let it pass | ||
| + | or <code>block</code> it, and the answer tells the caller whether to go on. | ||
| − | + | [[Manual:DIL Manual/send done()|send_done()]] is its partner, for the <code>SFB_DONE</code> event | |
| − | + | after the deed. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | == Parameters == | ||
| + | {| class="wikitable" | ||
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | cmd || string || The command, looked up like a typed command (<code>"north"</code>, <code>"flee"</code>). Receivers see it in <code>command(...)</code>. | ||
| + | |- | ||
| + | | who || unitptr || Who does it: the receivers' <code>activator</code>. | ||
| + | |- | ||
| + | | med || unitptr || The receivers' <code>medium</code>, or null. | ||
| + | |- | ||
| + | | tgt || unitptr || The receivers' <code>target</code>, or null. | ||
| + | |- | ||
| + | | pwr || integer || The receivers' <code>power</code>. | ||
| + | |- | ||
| + | | arg || string || The receivers' <code>argument</code>. | ||
| + | |- | ||
| + | | other || unitptr || A unit outside the room that should hear it too, or null. | ||
| + | |} | ||
| + | == Returns == | ||
| + | Integer, from <code>vme/include/vme.h</code>: <code>SFR_SHARE</code> when nobody blocked it, | ||
| + | <code>SFR_BLOCK</code> when a program blocked it. Stop when you get <code>SFR_BLOCK</code>. | ||
| − | + | It fails, and writes "Can not send_preprocess. No such command" to the zone's log, when | |
| − | + | <code>cmd</code> is empty or not a command. A wrong type in another argument also fails. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | == Notes == | |
| − | + | * With <code>who</code> null, nothing is sent and the result is <code>SFR_SHARE</code>. | |
| − | + | * It sends the event; it doesn't run the command. Do the deed yourself afterwards, or use | |
| − | + | [[Manual:DIL Manual/exec()|exec()]] when the real command will do. | |
| − | + | * A receiver changing <code>power</code> doesn't change your <code>pwr</code>. | |
| − | |||
| − | + | == Example == | |
| + | <pre> | ||
| + | dilbegin go_dir(dir : string, toroom : unitptr, arg : string); | ||
| + | var | ||
| + | res : integer; | ||
| + | code | ||
| + | { | ||
| + | res := send_pre(dir, self, null, null, 0, arg, null); | ||
| + | if (res != SFR_SHARE) | ||
| + | quit; | ||
| + | |||
| + | link(self, toroom); | ||
| + | act("$1n arrives.", A_HIDEINV, self, null, null, TO_ROOM); | ||
quit; | quit; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Moves a character a special way only if no guard or door program blocks the direction, as the | ||
| + | climbing code in basemove.zon does. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/send done()|send_done()]] | |
| − | + | * [[Manual:DIL Manual/exec()|exec()]] | |
| − | + | * [[Manual:DIL Manual/block|block]] | |
| − | + | * [[Manual:DIL Manual/wait()|wait()]] | |
| − | + | * [[Manual:DIL Manual/command()|command()]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:20, 14 November 2026
send_pre()
Function (integer). Asks the programs around a character whether a command may go ahead.
send_pre(cmd : string, who : unitptr, med : unitptr, tgt : unitptr, pwr : integer,
arg : string, other : unitptr)
When a DIL does something on a character's behalf that a command would normally do (moving,
fleeing), other programs expect to hear about it first: a guard that blocks an exit waits with
wait(SFB_PRE, command("north") ...). send_pre() sends that SFB_PRE
event as if who had typed the command, to the programs the command itself would
reach: those in the room, on the room, and on what who carries. Each can let it pass
or block it, and the answer tells the caller whether to go on.
send_done() is its partner, for the SFB_DONE event
after the deed.
Parameters
| Name | Type | Meaning |
|---|---|---|
| cmd | string | The command, looked up like a typed command ("north", "flee"). Receivers see it in command(...).
|
| who | unitptr | Who does it: the receivers' activator.
|
| med | unitptr | The receivers' medium, or null.
|
| tgt | unitptr | The receivers' target, or null.
|
| pwr | integer | The receivers' power.
|
| arg | string | The receivers' argument.
|
| other | unitptr | A unit outside the room that should hear it too, or null. |
Returns
Integer, from vme/include/vme.h: SFR_SHARE when nobody blocked it,
SFR_BLOCK when a program blocked it. Stop when you get SFR_BLOCK.
It fails, and writes "Can not send_preprocess. No such command" to the zone's log, when
cmd is empty or not a command. A wrong type in another argument also fails.
Notes
- With
whonull, nothing is sent and the result isSFR_SHARE. - It sends the event; it doesn't run the command. Do the deed yourself afterwards, or use
exec() when the real command will do.
- A receiver changing
powerdoesn't change yourpwr.
Example
dilbegin go_dir(dir : string, toroom : unitptr, arg : string);
var
res : integer;
code
{
res := send_pre(dir, self, null, null, 0, arg, null);
if (res != SFR_SHARE)
quit;
link(self, toroom);
act("$1n arrives.", A_HIDEINV, self, null, null, TO_ROOM);
quit;
}
dilend
Moves a character a special way only if no guard or door program blocks the direction, as the climbing code in basemove.zon does.