Manual:DIL Manual/send pre()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:20, 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_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 who null, nothing is sent and the result is SFR_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 power doesn't change your pwr.

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.

See also