From 3e75dede1b744fa9a6b7cad00039620de01fb2e2 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 7 Jan 2008 02:12:06 +0000
Subject: Persistent prim inventory phase 5. Restart scripts contained in
persisted prims on region start. No user functionality exposed yet - no ini
switch to enable persistence or restore. A bit more initial work to do.
---
.../Scenes/SceneObjectPart.Inventory.cs | 48 ++++++++++++++++++++++
1 file changed, 48 insertions(+)
(limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs')
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index aab2291..5f93986 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -33,6 +33,7 @@ using System.Xml.Serialization;
using libsecondlife;
using OpenSim.Framework;
+using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes.Scripting;
@@ -79,6 +80,53 @@ namespace OpenSim.Region.Environment.Scenes
{
get { return m_inventorySerial; }
}
+
+
+ ///
+ /// Start all the scripts contained in this prim's inventory
+ ///
+ public void StartScripts()
+ {
+ foreach (TaskInventoryItem item in m_taskInventory.Values)
+ {
+ if ("lsltext" == item.type)
+ {
+ StartScript(item);
+ }
+ }
+ }
+
+ ///
+ /// Start a script in this prim
+ ///
+ ///
+ /// true if script asset was found, false if it wasn't
+ public bool StartScript(TaskInventoryItem item)
+ {
+// MainLog.Instance.Verbose(
+// "PRIMINVENTORY",
+// "Starting script {0}, {1} in prim {2}, {3}",
+// item.name, item.item_id, Name, UUID);
+
+ AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.asset_id, false);
+
+ if (rezAsset != null)
+ {
+ string script = Helpers.FieldToUTF8String(rezAsset.Data);
+ m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.item_id, script);
+
+ return true;
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Couldn't start script {0}, {1} since asset ID {2} could not be found",
+ item.name, item.item_id, item.asset_id);
+ }
+
+ return false;
+ }
///
/// Add an item to this prim's inventory.
--
cgit v1.1