mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 03:45:35 +08:00
Make "show object part" command correctly display script status.
Uses new IEntityInventory.TryGetScriptInstanceRunning() Makes it clearer that TaskInventoryItem.ScriptRunning cannot be used as it is temporary and not updated.
This commit is contained in:
@@ -149,6 +149,19 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||
/// <param name="itemId"></param>
|
||||
void StopScriptInstance(UUID itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Try to get the script running status.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Returns true if a script for the item was found in one of the simulator's script engines. In this case,
|
||||
/// the running parameter will reflect the running status.
|
||||
/// Returns false if the item could not be found, if the item is not a script or if a script instance for the
|
||||
/// item was not found in any of the script engines. In this case, running status is irrelevant.
|
||||
/// </returns>
|
||||
/// <param name='itemId'></param>
|
||||
/// <param name='running'></param>
|
||||
bool TryGetScriptInstanceRunning(UUID itemId, out bool running);
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
|
||||
/// name is chosen.
|
||||
|
||||
@@ -232,31 +232,49 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
|
||||
return;
|
||||
|
||||
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||
if (engines == null) // No engine at all
|
||||
return;
|
||||
|
||||
lock (Items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in Items.Values)
|
||||
{
|
||||
if (item.InvType == (int)InventoryType.LSL)
|
||||
{
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
bool running;
|
||||
|
||||
if (e.HasScript(item.ItemID, out running))
|
||||
{
|
||||
item.ScriptRunning = running;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool running;
|
||||
if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running))
|
||||
item.ScriptRunning = running;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetScriptInstanceRunning(UUID itemId, out bool running)
|
||||
{
|
||||
running = false;
|
||||
|
||||
TaskInventoryItem item = GetInventoryItem(itemId);
|
||||
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
return TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running);
|
||||
}
|
||||
|
||||
public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running)
|
||||
{
|
||||
running = false;
|
||||
|
||||
if (item.InvType != (int)InventoryType.LSL)
|
||||
return false;
|
||||
|
||||
IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>();
|
||||
if (engines == null) // No engine at all
|
||||
return false;
|
||||
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
if (e.HasScript(item.ItemID, out running))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
int scriptsValidForStarting = 0;
|
||||
|
||||
Reference in New Issue
Block a user