From f2c449f10e7c6b7dc3468ecdaea9e97039e1e0a9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 15 Jul 2007 22:04:56 +0000 Subject: * Added new scripting related events, in particular a new event which is triggered by console commands so that the script can subscribe to console messages and operate when they occur. * Added new example script (work in progress) * Fixed typo in Scripting engines for C# and JScript.NET --- OpenSim/Region/Application/OpenSimMain.cs | 8 +++++- OpenSim/Region/Environment/Scenes/Scene.cs | 9 ++++++ OpenSim/Region/Environment/Scenes/SceneEvents.cs | 9 ++++++ .../Engines/CSharpEngine/CSharpScriptEngine.cs | 2 +- .../CSharpEngine/Examples/ExportRegionToLSL.cs | 32 ++++++++++++++++++++++ .../Engines/JScriptEngine/JScriptEngine.cs | 2 +- 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index ab03ed1..6968c41 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -422,7 +422,7 @@ namespace OpenSim { case "help": m_log.Error("show users - show info about connected users"); - m_log.Error("shutdown - disconnect all clients and shutdown"); + m_log.Error("quit - disconnect all clients and shutdown"); break; case "show": @@ -442,6 +442,12 @@ namespace OpenSim } } break; + case "script": + for (int i = 0; i < m_localWorld.Count; i++) + { + ((Scene)m_localWorld[i]).SendCommandToScripts(cmdparams); + } + break; case "quit": case "shutdown": diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index bb9fa61..aa08172 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -164,6 +164,15 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + #region Script Handling Methods + + public void SendCommandToScripts(string[] args) + { + m_eventManager.TriggerOnScriptConsole(args); + } + + #endregion + /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index f8ebb2f..1e4b163 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -25,6 +25,15 @@ namespace OpenSim.Region.Environment.Scenes public delegate void OnParcelPrimCountAddDelegate(SceneObject obj); public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; + public delegate void OnScriptConsoleDelegate(string[] args); + public event OnScriptConsoleDelegate OnScriptConsole; + + public void TriggerOnScriptConsole(string[] args) + { + if (OnScriptConsole != null) + OnScriptConsole(args); + } + public void TriggerOnFrame() { if (OnFrame != null) diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs index 9a3d229..1fc576e 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Scripting compilerParams.GenerateInMemory = true; compilerParams.IncludeDebugInformation = false; compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); compilerParams.ReferencedAssemblies.Add("System.dll"); diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs new file mode 100644 index 0000000..4cc2c96 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs @@ -0,0 +1,32 @@ +using OpenSim.Framework.Console; +using OpenSim.Framework; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.Scripting.Examples +{ + public class LSLExportScript : IScript + { + ScriptInfo script; + + public string getName() + { + return "LSL Export Script 0.1"; + } + + public void Initialise(ScriptInfo scriptInfo) + { + script = scriptInfo; + + script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(events_OnScriptConsole); + } + + void events_OnScriptConsole(string[] args) + { + if (args[0].ToLower() == "lslexport") + { + + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs index 9145492..0833e7a 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Scripting compilerParams.GenerateInMemory = true; compilerParams.IncludeDebugInformation = false; compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); - compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll"); + compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); compilerParams.ReferencedAssemblies.Add("System.dll"); -- cgit v1.1