Starting to use the scripting extensions
parent
4ed2de0a43
commit
307191eb40
|
@ -37,9 +37,11 @@ using System.Threading;
|
|||
using log4net;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using Mono.Addins;
|
||||
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
|
||||
|
||||
[assembly: Addin("OpenSimBirds", "0.2")]
|
||||
[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
|
||||
|
@ -52,7 +54,7 @@ namespace Flocking
|
|||
#region Fields
|
||||
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 Scene m_scene;
|
||||
private ICommandConsole m_console;
|
||||
|
@ -93,37 +95,37 @@ namespace Flocking
|
|||
}
|
||||
|
||||
public void AddRegion (Scene scene)
|
||||
{
|
||||
{
|
||||
IConfig cnf;
|
||||
m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName);
|
||||
|
||||
cnf = m_config.Configs["Startup"];
|
||||
m_log.InfoFormat("[{0}]: Adding region {1} to this module", m_name, scene.RegionInfo.RegionName);
|
||||
|
||||
cnf = m_config.Configs["Startup"];
|
||||
m_regionConfigDir = cnf.GetString("regionload_regionsdir", Path.Combine(Util.configDir(), "bin/Regions/"));
|
||||
|
||||
cnf = m_config.Configs[scene.RegionInfo.RegionName];
|
||||
|
||||
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);
|
||||
//string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini");
|
||||
string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini");
|
||||
try
|
||||
{
|
||||
m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section containing valid config keys", m_name, moduleConfigFile, scene.RegionInfo.RegionName);
|
||||
m_config = new IniConfigSource(moduleConfigFile);
|
||||
cnf = m_config.Configs[scene.RegionInfo.RegionName];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
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_enabled = false;
|
||||
return;
|
||||
}
|
||||
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);
|
||||
//string moduleConfigFile = Path.Combine(Util.configDir(),m_name + ".ini");
|
||||
string moduleConfigFile = Path.Combine(m_regionConfigDir, "Regions.ini");
|
||||
try
|
||||
{
|
||||
m_log.InfoFormat("[{0}]: Checking {1} for [{2}] section containing valid config keys", m_name, moduleConfigFile, scene.RegionInfo.RegionName);
|
||||
m_config = new IniConfigSource(moduleConfigFile);
|
||||
cnf = m_config.Configs[scene.RegionInfo.RegionName];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
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_enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_enabled = cnf.GetBoolean("BirdsEnabled", false);
|
||||
|
@ -337,6 +339,21 @@ namespace Flocking
|
|||
AddCommand("stats", "", "Show birds stats", HandleShowStatsCmd);
|
||||
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 ()
|
||||
{
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
<Reference name="OpenMetaverseTypes"/>
|
||||
<Reference name="OpenMetaverse.StructuredData"/>
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Framework.Communications"/>
|
||||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="OpenSim.Region.Framework"/>
|
||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
||||
<Reference name="Nini"/>
|
||||
<Reference name="log4net"/>
|
||||
<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>
|
||||
<Match pattern="*.cs" recurse="true">
|
||||
|
|
Loading…
Reference in New Issue