Manual:DIL Manual/sendto()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:16, 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

sendto()

Procedure. Sends a message to the DIL programs on one unit.

sendto(msg : string, u : unitptr)

Every DIL program on u that is waiting for SFB_MSG (in a wait() or an interrupt()) gets the message. The receivers run at once, before sendto() returns. In each of them argument is the message and activator is the sender's unit; medium and target are null.

The unit can be anywhere in the game. Only the programs on u itself get the message, not those on what it contains.

Parameters

Name Type Meaning
msg string The message. Receivers usually compare it with argument.
u unitptr The unit whose programs get it.

Notes

  • sendto(msg, self) reaches the other programs on the sender's own unit, aware or not. The sending program itself never gets its own message.
  • A program that isn't waiting for SFB_MSG at that moment misses the message; it isn't kept for later.
  • The programs on u get it in fnpri order. One that does block or holds priority keeps it from the ones after it.
  • Nothing happens when u or the message is null.
  • Afterwards the sender's secures are tested: if a receiver moved a secured unit away, the sender goes to that secure's label.

Example

dilbegin call_captain();
var
   capt : unitptr;
code
{
   heartbeat := PULSE_SEC * 30;
:start:
   wait(SFB_COM, TRUE);
   capt := findsymbolic("captain@ex");
   if (capt != null)
      sendto("alarm " + self.outside.name, capt);
   pause;
   goto start;
}
dilend

dilbegin captain();
code
{
:start:
   wait(SFB_MSG, "alarm" in argument);
   exec("shout To arms! " + activator.name + " needs help!", self);
   goto start;
}
dilend

A guard in a fight calls the captain, wherever the captain is, at most every 30 seconds. In haon_dor.zon the orc chief tells Mary she has lost her pot with sendto("gotit", u1).

See also