Difference between revisions of "Manual:DIL Manual/sendtoalldil()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bpsendalld"></span>
+
= sendtoalldil() =
−
sendtoalldil( m : string, s : string )
+
'''Procedure.''' Sends a message to every running copy of a DIL template.
−
    m : Message to send.
 
−
    s : Name idx to a DIL program to send message to.
 
−
    result: Send a message to all DIL programs matching a given database name.
 
  
−
  '''Example:'''
+
  sendtoalldil(m : string, s : string)
  
−
    sendtoalldil ( "some message", "intercomm@cemetery");
+
Sends the message <code>m</code> to every program in the game made from the template
 +
<code>s</code> (<code>"name@zone"</code>), on whatever unit it runs. Each such program that waits
 +
for <code>SFB_MSG</code> wakes up with <code>m</code> in <code>argument</code>, the sending unit
 +
as <code>activator</code> and <code>medium</code>, and its own unit as <code>target</code>.
 +
channel@function uses it to carry the chat channels to every player.
  
−
    The message "some message" is sent to all DIL program in the world
+
== Parameters ==
−
    matching the data base name "intercomm@cemetery".
+
{| class="wikitable"
−
    Like 'send()' and 'sendto()', the
+
! Name !! Type !! Meaning
−
    message received matches the SFB_MSG message class.
+
|-
 +
| m || string || The message.
 +
|-
 +
| s || string || The template's name with its zone, <code>"name@zone"</code>.
 +
|}
  
−
---~---~---~---~---~---~---~---~---
+
== Notes ==
−
<span id="bpsendalld"></span>
+
* Without the <code>@zone</code>, or for a template that doesn't exist, nothing is sent.
−
sendtoalldil( m : string, s : string )
+
* The sending program itself never gets the message. Another copy on the same unit gets it only when it is <code>aware</code>.
−
    m : Message to send.
+
* Only programs made from that template (copied onto a unit) are reached, and only while they are in the template itself: one that waits inside a function it called gets nothing, and so does a program of another template that calls <code>s</code> as a function.
−
    s : Name idx to a DIL program to send message to.
+
* The messages are delivered at once, before <code>sendtoalldil()</code> returns: the receivers run first.
−
    result: Send a message to all DIL programs matching a given database name.
+
* A program waiting for something else gets nothing (unless an <code>interrupt(SFB_MSG, ...)</code> catches it).
  
−
'''Example:'''
+
== Example ==
 +
<pre>
 +
dilbegin raise_alarm();
 +
code
 +
{
 +
  sendtoalldil("alarm " + self.outside.title, "gate_guard@castle");
 +
  quit;
 +
}
 +
dilend
  
−
    sendtoalldil ( "some message", "intercomm@cemetery");
+
dilbegin gate_guard();
 +
var
 +
  s : string;
 +
  w : string;
 +
code
 +
{
 +
  :start:
 +
  wait(SFB_MSG, "alarm" in argument);
 +
  s := argument;
 +
  w := getword(s);                  // takes "alarm" off s
 +
  exec("shout To arms! Trouble at " + s + "!", self);
 +
  goto start;
 +
}
 +
dilend
 +
</pre>
 +
Raises the alarm with every gate guard (template <code>gate_guard</code> in a zone named castle), wherever the guards are.
  
−
    The message "some message" is sent to all DIL program in the world
+
== See also ==
−
    matching the data base name "intercomm@cemetery".
+
* [[Manual:DIL Manual/sendtoall()|sendtoall()]]
−
    Like 'send()' and 'sendto()', the
+
* [[Manual:DIL Manual/sendto()|sendto()]]
−
    message received matches the SFB_MSG message class.
+
* [[Manual:DIL Manual/send()|send()]]
−
 
+
* [[Manual:DIL Manual/wait()|wait()]]
−
---~---~---~---~---~---~---~---~---
+
* [[Manual:DIL Manual/interrupt()|interrupt()]]

Latest revision as of 23:22, 14 November 2026

sendtoalldil()

Procedure. Sends a message to every running copy of a DIL template.

sendtoalldil(m : string, s : string)

Sends the message m to every program in the game made from the template s ("name@zone"), on whatever unit it runs. Each such program that waits for SFB_MSG wakes up with m in argument, the sending unit as activator and medium, and its own unit as target. channel@function uses it to carry the chat channels to every player.

Parameters

Name Type Meaning
m string The message.
s string The template's name with its zone, "name@zone".

Notes

  • Without the @zone, or for a template that doesn't exist, nothing is sent.
  • The sending program itself never gets the message. Another copy on the same unit gets it only when it is aware.
  • Only programs made from that template (copied onto a unit) are reached, and only while they are in the template itself: one that waits inside a function it called gets nothing, and so does a program of another template that calls s as a function.
  • The messages are delivered at once, before sendtoalldil() returns: the receivers run first.
  • A program waiting for something else gets nothing (unless an interrupt(SFB_MSG, ...) catches it).

Example

dilbegin raise_alarm();
code
{
   sendtoalldil("alarm " + self.outside.title, "gate_guard@castle");
   quit;
}
dilend

dilbegin gate_guard();
var
   s : string;
   w : string;
code
{
   :start:
   wait(SFB_MSG, "alarm" in argument);
   s := argument;
   w := getword(s);                  // takes "alarm" off s
   exec("shout To arms! Trouble at " + s + "!", self);
   goto start;
}
dilend

Raises the alarm with every gate guard (template gate_guard in a zone named castle), wherever the guards are.

See also