<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://wiki.lostsouls.org/w/skins/common/feed.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Man chatter - Revision history</title>
		<link>http://wiki.lostsouls.org/w/index.php?title=Man_chatter&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.8.2</generator>
		<lastBuildDate>Sun, 03 May 2026 11:41:10 GMT</lastBuildDate>
		<item>
			<title>Laine at 00:59, 12 June 2007</title>
			<link>http://wiki.lostsouls.org/w/index.php?title=Man_chatter&amp;diff=4023&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
Detailed below are the functions found in the chatter daemon, followed&lt;br /&gt;
by a brief description of how to use them to set up chatter in rooms.&lt;br /&gt;
&lt;br /&gt;
 varargs status add_chatter(string chatter_id, mixed *chatter, int interval,&lt;br /&gt;
 mixed what, status cycling) &lt;br /&gt;
&lt;br /&gt;
chatter_id - The chatter daemon keeps track of separate chatters by&lt;br /&gt;
assigning them each a unique chatter_id.  This argument should be a string with&lt;br /&gt;
some sort of information about the chatter, e.g. &amp;quot;Northlands Wind&amp;quot; or &amp;quot;Camelot&lt;br /&gt;
Moat&amp;quot;.  &lt;br /&gt;
&lt;br /&gt;
chatter - Traditionally, this argument has been an array of strings.&lt;br /&gt;
However, the elements of this can also be closures.  The closures will be given&lt;br /&gt;
the argument of the room the chatter is happening in.  An example of *chatter&lt;br /&gt;
might be:       &lt;br /&gt;
                ({ &amp;quot;The wind whistles around you.\n&amp;quot;,&lt;br /&gt;
		   &amp;quot;Birds chirp in the distance.\n&amp;quot;,&lt;br /&gt;
		   &amp;quot;The water laps gently at the shore.\n&amp;quot;,&lt;br /&gt;
		   lambda(({'x}),({#'call_other,'x,&amp;quot;do_stuff&amp;quot;})),&lt;br /&gt;
		})&lt;br /&gt;
The first three are fairly easy to understand.  The fourth element here&lt;br /&gt;
is a closure, which will cause the function do_stuff() to be called in every &lt;br /&gt;
room which is affected by this chatter.  The implications of this may not be&lt;br /&gt;
readily apparent, but it makes it possible for chatter to trigger events and &lt;br /&gt;
the like.  For instance, do_stuff() might look like this in the room's code:&lt;br /&gt;
&lt;br /&gt;
  void do_stuff() {&lt;br /&gt;
      tell_room(this_object(),&amp;quot;Fixy is upset!  You all die!\n&amp;quot;); &lt;br /&gt;
      filter_array(all_livings(),#'call_other,&amp;quot;die&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
In this case, instead of having a nice chatter message broadcast to the&lt;br /&gt;
room, everyone who's alive in the room dies.  Beginning to see the power of &lt;br /&gt;
closures in chatter?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
interval - This argument sets how many seconds will elapse between each&lt;br /&gt;
burst of chatter.  It can be no smaller than 15, and must be a multiple of 15.&lt;br /&gt;
&lt;br /&gt;
what - This defines which rooms the chatter will occur in.  It can&lt;br /&gt;
either be a room, an array of rooms, or a closure.  There are a number of&lt;br /&gt;
pre-built closures in /lib/chatter_conditions.h which will cause the chatter&lt;br /&gt;
to occur in rooms of given realms, areas, etc.  If you want an area-wide&lt;br /&gt;
chatter, it is best to use a closure.  If you want the chatter to occur in only&lt;br /&gt;
a single room or a few rooms, it is best to give this argument a room or array&lt;br /&gt;
of rooms.  If add_chatter is called with a chatter_id that already exists and&lt;br /&gt;
the 'what' argument is not a closure, it will add the room(s) defined by the&lt;br /&gt;
new add_chatter to the rooms defined in the old add_chatter.  &lt;br /&gt;
&lt;br /&gt;
Keep in mind that if you give a closure argument as 'what', the closure&lt;br /&gt;
will be bound to the object that called add_chatter.  This means that things &lt;br /&gt;
will break if this object is destructed.  If you intend to use a closure, it&lt;br /&gt;
is a good idea to call add_chatter from a daemon or a room that will not &lt;br /&gt;
remove itself when empty.  &lt;br /&gt;
&lt;br /&gt;
It is also possible to give the file name of a room or an array of file&lt;br /&gt;
names for this argument.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cycling - If this argument is 1, then the chatter will proceed in order&lt;br /&gt;
and loop back to the beginning once it reaches the end.  This is useful if&lt;br /&gt;
it is important for chatter events to happen in a particular order.  The &lt;br /&gt;
default of 0 will cause the chatter line to be randomly picked from the chatter&lt;br /&gt;
array each time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting up chatter for your area===&lt;br /&gt;
&lt;br /&gt;
If you want chatter to happen only in a single room, build the add_chatter&lt;br /&gt;
call directly into the room's code.  Here's an example:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;daemons.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;My_Area.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 inherit My_Area_Base;&lt;br /&gt;
&lt;br /&gt;
 void create() {&lt;br /&gt;
 ::create();&lt;br /&gt;
     set_short(&amp;quot;an example room&amp;quot;);&lt;br /&gt;
     set_long(format(&amp;quot;What a boring long description.&amp;quot;));&lt;br /&gt;
         Chatter_Daemon-&amp;gt;add_chatter(&amp;quot;Test Chatter&amp;quot;, ({&lt;br /&gt;
             &amp;quot;The wind whistles by.\n&amp;quot;,&lt;br /&gt;
             &amp;quot;Trees rustle in the wind.\n&amp;quot;,&lt;br /&gt;
             &amp;quot;Footsteps echo throughout the canyon.\n&amp;quot;, &lt;br /&gt;
         }), 30, this_object() );&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
To make an entire area chatter, one would write a daemon not unlike this one:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;daemons.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;chatter_conditions.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 void create() {&lt;br /&gt;
 	 Chatter_Daemon-&amp;gt;add_chatter(&amp;quot;Area Chatter&amp;quot;, ({&lt;br /&gt;
         &amp;quot;Eerie drums beat all around you.\n&amp;quot;,&lt;br /&gt;
         &amp;quot;The ground shakes.\n&amp;quot;,&lt;br /&gt;
         &amp;quot;Voices drift by on the wind.\n&amp;quot;,&lt;br /&gt;
         }), 45, In_Area(&amp;quot;My Area&amp;quot;) );&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Once the daemon is created, add a line similar to this to your area's&lt;br /&gt;
Base.c file: &lt;br /&gt;
&lt;br /&gt;
	My_Area_Daemon(&amp;quot;chatter&amp;quot;)-&amp;gt;load();&lt;br /&gt;
&lt;br /&gt;
===More on closures===&lt;br /&gt;
&lt;br /&gt;
An array of all of the users' environments is filtered through the closure;&lt;br /&gt;
if '1' is returned, then the chatter message is broadcast to the room.  &lt;br /&gt;
The closures can be combined using the Combine(a,b) closure as defined in&lt;br /&gt;
chatter_conditions.h.  For instance, if you wanted to have a chatter be &lt;br /&gt;
broadcast to all rooms that are have set_exposure &amp;gt;= Exposure_Open and are in&lt;br /&gt;
the realm &amp;quot;MyRealm&amp;quot;, the appropriate closure would be this:&lt;br /&gt;
&lt;br /&gt;
	Combine(Is_Outdoors(Exposure_Open), In_Realm(&amp;quot;MyRealm&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
You can embed a 'Combine' closure within another 'Combine' closure to create&lt;br /&gt;
as many conditions as you desire:&lt;br /&gt;
	&lt;br /&gt;
	Combine(Is_Outdoors(2),Combine(In_Realm(&amp;quot;MyRealm&amp;quot;),&lt;br /&gt;
	  In_Area(&amp;quot;This Area&amp;quot;)))&lt;/div&gt;</description>
			<pubDate>Tue, 12 Jun 2007 00:59:39 GMT</pubDate>			<dc:creator>Laine</dc:creator>			<comments>http://wiki.lostsouls.org/Talk:Man_chatter</comments>		</item>
	</channel>
</rss>