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 +++++++++++++++++++++-
OpenSim/Region/Environment/Scenes/Scene.cs | 1 +
OpenSim/Region/Environment/Scenes/SceneEvents.cs | 11 ++++++
.../Region/Environment/Scenes/SceneObjectPart.cs | 9 +++++
4 files changed, 63 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Environment')
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;
}
+
+
}
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index cdf6788..d625dec 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -711,6 +711,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += commsManager.TransactionsManager.HandleXfer;
// client.OnRequestXfer += RequestXfer;
+ client.OnRezScript += RezScript;
client.OnRequestAvatarProperties += RequestAvatarProperty;
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 050207c..89aeda6 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -37,6 +37,9 @@ namespace OpenSim.Region.Environment.Scenes
public event ObjectGrabDelegate OnObjectGrab;
public event OnPermissionErrorDelegate OnPermissionError;
+ public delegate void NewRezScript(uint localID, string script);
+ public event NewRezScript OnRezScript;
+
public void TriggerPermissionError(LLUUID user, string reason)
{
@@ -106,5 +109,13 @@ namespace OpenSim.Region.Environment.Scenes
if (OnObjectGrab != null)
OnObjectGrab(localID, offsetPos, remoteClient);
}
+
+ public void TriggerRezScript(uint localID, string script)
+ {
+ if (OnRezScript != null)
+ {
+ OnRezScript(localID, script);
+ }
+ }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index de3ad38..904b158 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -396,6 +396,15 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Inventory
+ public void AddInventoryItem()
+ {
+
+ }
+
+ public void RemoveInventoryItem()
+ {
+
+ }
///
///
///
--
cgit v1.1