From 16d5ce16b60bba8b5c98b95606f369702721175d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 14 Jan 2012 00:44:19 +0000 Subject: [PATCH] Extend scripts show command to accept a single item UUID parameter to display one script's status Usage is now scripts show [] --- .../Region/ScriptEngine/XEngine/XEngine.cs | 87 ++++++++++--------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 12e1a78871..c9bbf0e0c0 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -273,11 +273,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine } MainConsole.Instance.Commands.AddCommand( - "scripts", false, "scripts show", "scripts show", "Show script information", - "Show information on all scripts known to the script engine", HandleShowScripts); + "scripts", false, "scripts show", "scripts show []", "Show script information", + "Show information on all scripts known to the script engine." + + "If a is given then only information on that script will be shown.", + HandleShowScripts); MainConsole.Instance.Commands.AddCommand( - "scripts", false, "show scripts", "show scripts", "Show script information", + "scripts", false, "show scripts", "show scripts []", "Show script information", "Synonym for scripts show command", HandleShowScripts); MainConsole.Instance.Commands.AddCommand( @@ -308,43 +310,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); } - public void HandleShowScripts(string module, string[] cmdparams) - { - lock (m_Scripts) - { - MainConsole.Instance.OutputFormat( - "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); - - foreach (IScriptInstance instance in m_Scripts.Values) - { - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - string status; - - if (instance.ShuttingDown) - { - status = "shutting down"; - } - else if (instance.Suspended) - { - status = "suspended"; - } - else if (!instance.Running) - { - status = "stopped"; - } - else - { - status = "running"; - } - - MainConsole.Instance.OutputFormat( - "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); - } - } - } - /// /// Parse the raw item id into a script instance from the command params if it's present. /// @@ -394,6 +359,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + public void HandleShowScripts(string module, string[] cmdparams) + { + if (cmdparams.Length == 2) + { + lock (m_Scripts) + { + MainConsole.Instance.OutputFormat( + "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); + } + } + + HandleScriptsAction(cmdparams, HandleShowScript); + } + + private void HandleShowScript(IScriptInstance instance) + { + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + string status; + + if (instance.ShuttingDown) + { + status = "shutting down"; + } + else if (instance.Suspended) + { + status = "suspended"; + } + else if (!instance.Running) + { + status = "stopped"; + } + else + { + status = "running"; + } + + MainConsole.Instance.OutputFormat( + "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, + sop.AbsolutePosition, status); + } + private void HandleSuspendScript(IScriptInstance instance) { if (!instance.Suspended)