Starting to use the scripting extensions

pull/1/merge
Jak Daniels 2015-09-23 19:57:27 +01:00
parent 4ed2de0a43
commit 307191eb40
2 changed files with 47 additions and 30 deletions

View File

@ -37,9 +37,11 @@ using System.Threading;
using log4net; using log4net;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using Mono.Addins; using Mono.Addins;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
[assembly: Addin("OpenSimBirds", "0.2")] [assembly: Addin("OpenSimBirds", "0.2")]
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
@ -52,7 +54,7 @@ namespace Flocking
#region Fields #region Fields
private static readonly ILog m_log = LogManager.GetLogger (System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger (System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType);
public string m_name = "OpenSimBirds"; public string m_name = "OpenSimBirds";
private string m_regionConfigDir = ""; private string m_regionConfigDir = "";
private Scene m_scene; private Scene m_scene;
private ICommandConsole m_console; private ICommandConsole m_console;
@ -93,37 +95,37 @@ namespace Flocking
} }
public void AddRegion (Scene scene) public void AddRegion (Scene scene)
{ {
IConfig cnf; IConfig cnf;
m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName);
cnf = m_config.Configs["Startup"]; cnf = m_config.Configs["Startup"];
m_regionConfigDir = cnf.GetString("regionload_regionsdir", Path.Combine(Util.configDir(), "bin/Regions/")); m_regionConfigDir = cnf.GetString("regionload_regionsdir", Path.Combine(Util.configDir(), "bin/Regions/"));
cnf = m_config.Configs[scene.RegionInfo.RegionName]; cnf = m_config.Configs[scene.RegionInfo.RegionName];
if (cnf == null) if (cnf == null)
{ {
m_log.InfoFormat("[{0}]: No region section [{1}] found in addon-modules/{2}/config/*.ini configuration files.", m_name, scene.RegionInfo.RegionName, m_name); m_log.InfoFormat("[{0}]: No region section [{1}] found in addon-modules/{2}/config/*.ini configuration files.", m_name, scene.RegionInfo.RegionName, m_name);
//string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini"); //string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini");
string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini"); string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini");
try try
{ {
m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section containing valid config keys", m_name, moduleConfigFile, scene.RegionInfo.RegionName); m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section containing valid config keys", m_name, moduleConfigFile, scene.RegionInfo.RegionName);
m_config = new IniConfigSource(moduleConfigFile); m_config = new IniConfigSource(moduleConfigFile);
cnf = m_config.Configs[scene.RegionInfo.RegionName]; cnf = m_config.Configs[scene.RegionInfo.RegionName];
} }
catch (Exception) catch (Exception)
{ {
cnf = null; cnf = null;
} }
if (cnf == null) if (cnf == null)
{ {
m_log.InfoFormat("[{0}]: No region section [{1}] found in configuration {2}. Birds in this region are set to Disabled", m_name, scene.RegionInfo.RegionName, moduleConfigFile); m_log.InfoFormat("[{0}]: No region section [{1}] found in configuration {2}. Birds in this region are set to Disabled", m_name, scene.RegionInfo.RegionName, moduleConfigFile);
m_enabled = false; m_enabled = false;
return; return;
} }
} }
m_enabled = cnf.GetBoolean("BirdsEnabled", false); m_enabled = cnf.GetBoolean("BirdsEnabled", false);
@ -337,6 +339,21 @@ namespace Flocking
AddCommand("stats", "", "Show birds stats", HandleShowStatsCmd); AddCommand("stats", "", "Show birds stats", HandleShowStatsCmd);
AddCommand("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd); AddCommand("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd);
} }
private void RegisterScriptFunctions()
{
IScriptModuleComms comms = m_scene.RequestModuleInterface<IScriptModuleComms>();
if (comms != null)
{
comms.RegisterScriptInvocation(this, "birdsGetStats");
}
}
private string birdsGetStats(UUID host, UUID script, string stat)
{
return ""; //currently a placeholder
}
private bool ShouldHandleCmd () private bool ShouldHandleCmd ()
{ {

View File

@ -18,13 +18,13 @@
<Reference name="OpenMetaverseTypes"/> <Reference name="OpenMetaverseTypes"/>
<Reference name="OpenMetaverse.StructuredData"/> <Reference name="OpenMetaverse.StructuredData"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="Nini"/> <Reference name="Nini"/>
<Reference name="log4net"/> <Reference name="log4net"/>
<Reference name="Mono.Addins"/> <Reference name="Mono.Addins"/>
<Reference name="OpenSim.Framework" path="../../../bin/" />
<Reference name="OpenSim.Framework.Communications" path="../../../bin/" />
<Reference name="OpenSim.Framework.Console" path="../../../bin/" />
<Files> <Files>
<Match pattern="*.cs" recurse="true"> <Match pattern="*.cs" recurse="true">