<br />
<b>Warning</b>:  Parameter 1 to Language::getMagic() expected to be a reference, value given in <b>/var/www/sda/2/c/digigrids/wiki/includes/StubObject.php</b> on line <b>58</b><br />
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://digigrids.free.fr/wiki/skins//common/feed.css?207"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
		<id>http://digigrids.free.fr/wiki/index.php?action=history&amp;feed=atom&amp;title=OSSL_Script_Library%2FModSendCommand</id>
		<title>OSSL Script Library/ModSendCommand - Historique des versions</title>
		<link rel="self" type="application/atom+xml" href="http://digigrids.free.fr/wiki/index.php?action=history&amp;feed=atom&amp;title=OSSL_Script_Library%2FModSendCommand"/>
		<link rel="alternate" type="text/html" href="http://digigrids.free.fr/wiki/index.php?title=OSSL_Script_Library/ModSendCommand&amp;action=history"/>
		<updated>2026-07-30T19:09:31Z</updated>
		<subtitle>Historique pour cette page sur le wiki</subtitle>
		<generator>MediaWiki 1.15.1</generator>

	<entry>
		<id>http://digigrids.free.fr/wiki/index.php?title=OSSL_Script_Library/ModSendCommand&amp;diff=4544&amp;oldid=prev</id>
		<title>Djphil&amp;nbsp;:&amp;#32;Page créée avec « You can pass data back and forth between region modules and scripts using a script function called modSendCommand() which was introduced in OpenSimulator 0.6.9. This is an al… »</title>
		<link rel="alternate" type="text/html" href="http://digigrids.free.fr/wiki/index.php?title=OSSL_Script_Library/ModSendCommand&amp;diff=4544&amp;oldid=prev"/>
				<updated>2012-04-12T04:50:35Z</updated>
		
		<summary type="html">&lt;p&gt;Page créée avec « You can pass data back and forth between region modules and scripts using a script function called modSendCommand() which was introduced in OpenSimulator 0.6.9. This is an al… »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;You can pass data back and forth between region modules and scripts using a script function called modSendCommand() which was introduced in OpenSimulator 0.6.9. This is an alternative to manually patching in new script functions. Here's an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
== Enabling modSendCommand() ==&lt;br /&gt;
&lt;br /&gt;
The first thing is to enable modSendCommand() in OpenSim.ini. Make sure the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
AllowMODFunctions = true&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is set to true and uncommented.&lt;br /&gt;
&lt;br /&gt;
== The Region Module ==&lt;br /&gt;
&lt;br /&gt;
Secondly, we need a region module to listen for the data sent by modSendCommand() and send a reply.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using Nini.Config;&lt;br /&gt;
using OpenMetaverse;&lt;br /&gt;
using OpenSim.Region.Framework.Interfaces;&lt;br /&gt;
using OpenSim.Region.Framework.Scenes;&lt;br /&gt;
&lt;br /&gt;
namespace ModSendCommandExample&lt;br /&gt;
{&lt;br /&gt;
  public class MyRegionModule : IRegionModule&lt;br /&gt;
  {&lt;br /&gt;
    Scene m_scene;&lt;br /&gt;
    IScriptModuleComms m_commsMod;        &lt;br /&gt;
&lt;br /&gt;
    public string Name { get { return &amp;quot;MyRegionModule&amp;quot;; } }&lt;br /&gt;
    public bool IsSharedModule { get { return false; } }&lt;br /&gt;
    public void Close() {}&lt;br /&gt;
&lt;br /&gt;
    public void Initialise(Scene scene, IConfigSource source)&lt;br /&gt;
    {&lt;br /&gt;
       m_scene = scene;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void PostInitialise()&lt;br /&gt;
    {&lt;br /&gt;
      m_commsMod&lt;br /&gt;
        = m_scene.RequestModuleInterface&amp;lt;IScriptModuleComms&amp;gt;();&lt;br /&gt;
      m_commsMod.OnScriptCommand += ProcessScriptCommand;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    void ProcessScriptCommand(&lt;br /&gt;
      UUID scriptId,&lt;br /&gt;
      string reqId, string module, string input, string k)&lt;br /&gt;
    {&lt;br /&gt;
      if (&amp;quot;MYMOD&amp;quot; != module)&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
      string[] tokens&lt;br /&gt;
          = input.Split(&lt;br /&gt;
              new char[] { '|' }, StringSplitOptions.None);&lt;br /&gt;
&lt;br /&gt;
      string command = tokens[0];&lt;br /&gt;
      switch (command)&lt;br /&gt;
      {&lt;br /&gt;
        case &amp;quot;Greet&amp;quot;:&lt;br /&gt;
          string name = tokens[1];&lt;br /&gt;
          m_commsMod.DispatchReply(scriptId, 1, &amp;quot;Hello &amp;quot; + name, &amp;quot;&amp;quot;);&lt;br /&gt;
          break;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The module subscribes to the OnScriptCommand IScriptModuleComms event in PostInitialise(). When a script command event occurs, it checks that the module identifier is correct (MYMOD) and then splits the command into components delimited by a bar (|). This isn’t essential - it’s just one way of invoking arbitrary commands.&lt;br /&gt;
&lt;br /&gt;
In this case, the command name is the first component. If it’s “Greet”, then a reply is sent back using the supplied name argument which is the second component.&lt;br /&gt;
&lt;br /&gt;
== The In-world Script ==&lt;br /&gt;
&lt;br /&gt;
Here’s the in-world script that makes the call and receives the reply.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lsl&amp;gt;&lt;br /&gt;
default&lt;br /&gt;
{&lt;br /&gt;
  touch_start(integer total_number)&lt;br /&gt;
  {&lt;br /&gt;
    modSendCommand(&amp;quot;MYMOD&amp;quot;, &amp;quot;Greet|World&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  link_message(integer sender_num, integer num, string message, key id)&lt;br /&gt;
  {&lt;br /&gt;
    if (sender_num == -1)&lt;br /&gt;
    {&lt;br /&gt;
      llSay(0, message);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/lsl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, a touch triggers the command to the module. The script receives back the link_message event and says the data in-world.&lt;br /&gt;
&lt;br /&gt;
You can download compilable region module source and script code for this example from [http://justincc.org/downloads/src/ModSendCommandExample-1.0.zip here].&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
At the moment, this page is a simplified version of [http://justincc.org/blog/2010/07/16/passing-data-between-a-script-and-a-region-module-with-modsendcommand this blog post].&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;/div&gt;</summary>
		<author><name>Djphil</name></author>	</entry>

	</feed>