<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://opensimulator.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://opensimulator.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vin+seymore</id>
		<title>OpenSimulator - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://opensimulator.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vin+seymore"/>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/Special:Contributions/Vin_seymore"/>
		<updated>2026-05-16T05:18:34Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.19.9</generator>

	<entry>
		<id>http://opensimulator.org/wiki/OSSL_Script_Library/ModSendCommand</id>
		<title>OSSL Script Library/ModSendCommand</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/OSSL_Script_Library/ModSendCommand"/>
				<updated>2012-11-04T14:45:41Z</updated>
		
		<summary type="html">&lt;p&gt;Vin seymore: Added a reference to ModInvoke&lt;/p&gt;
&lt;hr /&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 Region Module Revisited ==&lt;br /&gt;
&lt;br /&gt;
This is an alternate version of the previous region module example. It addresses the new region module mechanism, which has been in place since at least 0.6.9. &lt;br /&gt;
&lt;br /&gt;
Specifically the newer interface INonSharedRegionModule is being used here. The in-world script stays untouched.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using Mono.Addins;&lt;br /&gt;
using Nini.Config;&lt;br /&gt;
using OpenSim.Region.Framework.Interfaces;&lt;br /&gt;
using OpenSim.Region.Framework.Scenes;&lt;br /&gt;
using OpenMetaverse;&lt;br /&gt;
&lt;br /&gt;
[assembly: Addin(&amp;quot;MyRegionModule&amp;quot;, &amp;quot;0.1&amp;quot;)]&lt;br /&gt;
[assembly: AddinDependency(&amp;quot;OpenSim&amp;quot;, &amp;quot;0.5&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
namespace ModSendCommandExample&lt;br /&gt;
{&lt;br /&gt;
	[Extension(Path = &amp;quot;/OpenSim/RegionModules&amp;quot;, NodeName = &amp;quot;RegionModule&amp;quot;)]&lt;br /&gt;
	public class MyRegionModule : INonSharedRegionModule&lt;br /&gt;
	{&lt;br /&gt;
		private Scene m_scene = null;&lt;br /&gt;
		private IScriptModuleComms m_commsMod = null;&lt;br /&gt;
		&lt;br /&gt;
		public string Name &lt;br /&gt;
		{&lt;br /&gt;
			get {&lt;br /&gt;
				return &amp;quot;MyRegionModule&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public Type ReplaceableInterface &lt;br /&gt;
		{&lt;br /&gt;
			get {&lt;br /&gt;
				return null;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public void Initialise(IConfigSource source) {}&lt;br /&gt;
		&lt;br /&gt;
		public void Close() {}&lt;br /&gt;
		&lt;br /&gt;
		public void AddRegion(Scene scene) &lt;br /&gt;
		{&lt;br /&gt;
			m_scene = scene;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public void RemoveRegion(Scene scene) {}&lt;br /&gt;
		&lt;br /&gt;
		public void RegionLoaded(Scene scene) &lt;br /&gt;
		{&lt;br /&gt;
			m_commsMod = 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(UUID scriptId, 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 = input.Split(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;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&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;pre&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;/pre&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;
Another method for in-world script / region module data exchange is [[OSSL Script Library/ModInvoke]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;/div&gt;</summary>
		<author><name>Vin seymore</name></author>	</entry>

	<entry>
		<id>http://opensimulator.org/wiki/OSSL_Script_Library/ModSendCommand</id>
		<title>OSSL Script Library/ModSendCommand</title>
		<link rel="alternate" type="text/html" href="http://opensimulator.org/wiki/OSSL_Script_Library/ModSendCommand"/>
				<updated>2012-11-04T14:11:01Z</updated>
		
		<summary type="html">&lt;p&gt;Vin seymore: Updated region module example for modSendCommand using interface INonSharedRegionModule&lt;/p&gt;
&lt;hr /&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 Region Module Revisited ==&lt;br /&gt;
&lt;br /&gt;
This is an alternate version of the previous region module example. It addresses the new region module mechanism, which has been in place since at least 0.6.9. &lt;br /&gt;
&lt;br /&gt;
Specifically the newer interface INonSharedRegionModule is being used here. The in-world script stays untouched.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using Mono.Addins;&lt;br /&gt;
using Nini.Config;&lt;br /&gt;
using OpenSim.Region.Framework.Interfaces;&lt;br /&gt;
using OpenSim.Region.Framework.Scenes;&lt;br /&gt;
using OpenMetaverse;&lt;br /&gt;
&lt;br /&gt;
[assembly: Addin(&amp;quot;MyRegionModule&amp;quot;, &amp;quot;0.1&amp;quot;)]&lt;br /&gt;
[assembly: AddinDependency(&amp;quot;OpenSim&amp;quot;, &amp;quot;0.5&amp;quot;)]&lt;br /&gt;
&lt;br /&gt;
namespace ModSendCommandExample&lt;br /&gt;
{&lt;br /&gt;
	[Extension(Path = &amp;quot;/OpenSim/RegionModules&amp;quot;, NodeName = &amp;quot;RegionModule&amp;quot;)]&lt;br /&gt;
	public class MyRegionModule : INonSharedRegionModule&lt;br /&gt;
	{&lt;br /&gt;
		private Scene m_scene = null;&lt;br /&gt;
		private IScriptModuleComms m_commsMod = null;&lt;br /&gt;
		&lt;br /&gt;
		public string Name &lt;br /&gt;
		{&lt;br /&gt;
			get {&lt;br /&gt;
				return &amp;quot;MyRegionModule&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public Type ReplaceableInterface &lt;br /&gt;
		{&lt;br /&gt;
			get {&lt;br /&gt;
				return null;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public void Initialise(IConfigSource source) {}&lt;br /&gt;
		&lt;br /&gt;
		public void Close() {}&lt;br /&gt;
		&lt;br /&gt;
		public void AddRegion(Scene scene) &lt;br /&gt;
		{&lt;br /&gt;
			m_scene = scene;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public void RemoveRegion(Scene scene) {}&lt;br /&gt;
		&lt;br /&gt;
		public void RegionLoaded(Scene scene) &lt;br /&gt;
		{&lt;br /&gt;
			m_commsMod = 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(UUID scriptId, 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 = input.Split(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;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&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;pre&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;/pre&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>Vin seymore</name></author>	</entry>

	</feed>