From c404760731ed75971bea610b14a9dd46450cb1f6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 19 Oct 2011 21:40:28 +0100 Subject: [PATCH] Add "scripts stop" and "scripts start" console commands. These will stop all running scripts and start all stopped scripts respectively. A stopped script does not save any events for later processing. --- .../Region/ScriptEngine/XEngine/XEngine.cs | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index acbf7dfc26..003e735922 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -276,17 +276,25 @@ namespace OpenSim.Region.ScriptEngine.XEngine "Synonym for scripts show command", HandleShowScripts); MainConsole.Instance.Commands.AddCommand( - "scripts", false, "scripts suspend", "scripts suspend", "Suspend all scripts", + "scripts", false, "scripts suspend", "scripts suspend", "Suspends all running scripts", "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" + " script that is currently processing an event.\n" + "Suspended scripts will continue to accumulate events but won't process them.", HandleSuspendScripts); MainConsole.Instance.Commands.AddCommand( - "scripts", false, "scripts resume", "scripts resume", "Resume all scripts", + "scripts", false, "scripts resume", "scripts resume", "Resumes all suspended scripts", "Resumes all currently suspended scripts.\n" + "Resumed scripts will process all events accumulated whilst suspended.", HandleResumeScripts); + + MainConsole.Instance.Commands.AddCommand( + "scripts", false, "scripts stop", "scripts stop", "Stops all running scripts", + HandleStopScripts); + + MainConsole.Instance.Commands.AddCommand( + "scripts", false, "scripts start", "scripts start", "Starts all stopped scripts", + HandleStartScripts); } public void HandleShowScripts(string module, string[] cmdparams) @@ -364,6 +372,44 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + public void HandleStartScripts(string module, string[] cmdparams) + { + lock (m_Scripts) + { + foreach (IScriptInstance instance in m_Scripts.Values) + { + if (!instance.Running) + { + instance.Start(); + + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + MainConsole.Instance.OutputFormat( + "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); + } + } + } + } + + public void HandleStopScripts(string module, string[] cmdparams) + { + lock (m_Scripts) + { + foreach (IScriptInstance instance in m_Scripts.Values) + { + if (instance.Running) + { + instance.Stop(0); + + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + MainConsole.Instance.OutputFormat( + "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); + } + } + } + } + public void RemoveRegion(Scene scene) { if (!m_Enabled)