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

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="bpsendall"></span>
+
= sendtoall() =
−
sendtoall( m : string, s : string )
+
'''Procedure.''' Sends a message to every copy of a unit in the game.
−
    m : Message to send.
 
−
    s : Name idx to send message to.
 
−
    result: Send a message to all units matching a given database name.
 
  
−
  '''Example:'''
+
  sendtoall(m : string, s : string)
  
−
    sendtoall ( "some message", "rabbit@haon-dor");
+
Sends the message <code>m</code> to every unit in the game made from the definition
 +
<code>s</code> (<code>"name@zone"</code>, e.g. every <code>"bag@arena"</code>). Each DIL
 +
program on those units that waits for <code>SFB_MSG</code> wakes up with <code>m</code> in
 +
<code>argument</code>, and the sending unit as <code>activator</code> and <code>medium</code>.
  
−
    The message "some message" is sent to all units in the world matching the
+
To reach the programs made from one template, wherever they run, use
−
    data base name "rabbit@haon-dor". Like 'send()' and 'sendto()', the
+
[[Manual:DIL Manual/sendtoalldil()|sendtoalldil()]]; to reach one unit,
−
    message received matches the SFB_MSG message class.
+
[[Manual:DIL Manual/sendto()|sendto()]].
  
−
---~---~---~---~---~---~---~---~---
+
== Parameters ==
−
<span id="bpsendall"></span>
+
{| class="wikitable"
−
sendtoall( m : string, s : string )
+
! Name !! Type !! Meaning
−
    m : Message to send.
+
|-
−
    s : Name idx to send message to.
+
| m || string || The message.
−
    result: Send a message to all units matching a given database name.
+
|-
 +
| s || string || The units' symbolic name with its zone, <code>"name@zone"</code>.
 +
|}
  
−
'''Example:'''
+
== Notes ==
 +
* Without the <code>@zone</code>, or for a name that doesn't exist, nothing is sent.
 +
* The messages are delivered at once, before <code>sendtoall()</code> returns: the receivers run first.
 +
* A program waiting for something else gets nothing (unless an <code>interrupt(SFB_MSG, ...)</code> catches it).
 +
* If the sending unit is itself such a unit, its own programs get the message only when they are <code>aware</code>.
 +
* A program that blocks or takes <code>priority</code> keeps the message from the programs after it on the same unit.
  
−
    sendtoall ( "some message", "rabbit@haon-dor");
+
== Example ==
 +
<pre>
 +
dilbegin arena_over();
 +
code
 +
{
 +
  sendtoall("emptyout", "bag@arena");
 +
  quit;
 +
}
 +
dilend
  
−
    The message "some message" is sent to all units in the world matching the
+
dilbegin bag_wait();
−
    data base name "rabbit@haon-dor". Like 'send()' and 'sendto()', the
+
code
−
    message received matches the SFB_MSG message class.
+
{
 +
  :start:
 +
  wait(SFB_MSG, argument == "emptyout");
 +
  if (self.outside.type == UNIT_ST_PC)
 +
      act("Your $2N disappears.", A_SOMEONE, self.outside, self, null, TO_CHAR);
 +
  destroy(self);
 +
  quit;
 +
}
 +
dilend
 +
</pre>
 +
When the arena closes, every arena bag in the game vanishes, as in arena.zon.
  
−
---~---~---~---~---~---~---~---~---
+
== See also ==
 +
* [[Manual:DIL Manual/sendtoalldil()|sendtoalldil()]]
 +
* [[Manual:DIL Manual/sendto()|sendto()]]
 +
* [[Manual:DIL Manual/send()|send()]]
 +
* [[Manual:DIL Manual/wait()|wait()]]
 +
* [[Manual:DIL Manual/interrupt()|interrupt()]]

Latest revision as of 23:22, 14 November 2026

sendtoall()

Procedure. Sends a message to every copy of a unit in the game.

sendtoall(m : string, s : string)

Sends the message m to every unit in the game made from the definition s ("name@zone", e.g. every "bag@arena"). Each DIL program on those units that waits for SFB_MSG wakes up with m in argument, and the sending unit as activator and medium.

To reach the programs made from one template, wherever they run, use sendtoalldil(); to reach one unit, sendto().

Parameters

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

Notes

  • Without the @zone, or for a name that doesn't exist, nothing is sent.
  • The messages are delivered at once, before sendtoall() returns: the receivers run first.
  • A program waiting for something else gets nothing (unless an interrupt(SFB_MSG, ...) catches it).
  • If the sending unit is itself such a unit, its own programs get the message only when they are aware.
  • A program that blocks or takes priority keeps the message from the programs after it on the same unit.

Example

dilbegin arena_over();
code
{
   sendtoall("emptyout", "bag@arena");
   quit;
}
dilend

dilbegin bag_wait();
code
{
   :start:
   wait(SFB_MSG, argument == "emptyout");
   if (self.outside.type == UNIT_ST_PC)
      act("Your $2N disappears.", A_SOMEONE, self.outside, self, null, TO_CHAR);
   destroy(self);
   quit;
}
dilend

When the arena closes, every arena bag in the game vanishes, as in arena.zon.

See also