diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 41b5aa86b6..bd2197e94d 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using System.Reflection; using System.Security; using System.Security.Policy; @@ -377,8 +378,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine /// /// /// - /// true if we're okay to proceed, false if not. + /// Basis on which to sort output. Can be null if no sort needs to take place private void HandleScriptsAction(string[] cmdparams, Action action) + { + HandleScriptsAction(cmdparams, action, null); + } + + /// + /// Parse the raw item id into a script instance from the command params if it's present. + /// + /// + /// + /// Basis on which to sort output. Can be null if no sort needs to take place + private void HandleScriptsAction( + string[] cmdparams, Action action, Func keySelector) { if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) return; @@ -390,7 +403,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (cmdparams.Length == 2) { - foreach (IScriptInstance instance in m_Scripts.Values) + IEnumerable scripts = m_Scripts.Values; + + if (keySelector != null) + scripts = scripts.OrderBy(keySelector); + + foreach (IScriptInstance instance in scripts) action(instance); return; @@ -478,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - HandleScriptsAction(cmdparams, HandleShowScript); + HandleScriptsAction(cmdparams, HandleShowScript, si => si.EventsProcessed); } private void HandleShowScript(IScriptInstance instance)