From 921ac14e86fab329c3135b24b2a1be83813fce1b Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 21 Aug 2007 21:03:18 +0000 Subject: Added OnRezScript event to Scene.EventManager.Which the script engine should subscribe to. This is triggered whenever a script is moved into a primitive (and includes the localid of the prim and the script text as params) . Currently though the script item isn't deleted from a users inventory, nor does it actually show up in the objects inventory (this will be fixed soon.) So that means that it isn't currently possible to edit a script (or delete it) once it has been added to a primitive. --- .../Region/Environment/Scenes/Scene.Inventory.cs | 44 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 3e2a97a..765fafc 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -111,8 +111,8 @@ namespace OpenSim.Region.Environment.Scenes { asset.Name = item.inventoryName; asset.Description = item.inventoryDescription; - asset.InvType = (sbyte) item.invType; - asset.Type = (sbyte) item.assetType; + asset.InvType = (sbyte)item.invType; + asset.Type = (sbyte)item.assetType; item.assetID = asset.FullID; if (addToCache) @@ -205,6 +205,44 @@ namespace OpenSim.Region.Environment.Scenes } } + public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + bool isTexture = false; + if (item.invType == 0) + { + isTexture = true; + } + AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); + if (rezAsset != null) + { + string script = Util.FieldToString(rezAsset.Data); + //Console.WriteLine("rez script "+script); + this.EventManager.TriggerRezScript(localID, script); + } + else + { + //lets try once more incase the asset cache is being slow getting the asset from server + rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); + if (rezAsset != null) + { + string script = Util.FieldToString(rezAsset.Data); + // Console.WriteLine("rez script " + script); + this.EventManager.TriggerRezScript(localID, script); + } + } + } + } + } + } + /// /// /// @@ -320,6 +358,8 @@ namespace OpenSim.Region.Environment.Scenes this.AddEntity(group); group.AbsolutePosition = pos; } + + } } -- cgit v1.1