aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-05 00:05:06 +0100
committerJustin Clark-Casey (justincc)2012-07-05 00:05:06 +0100
commit951b45b80fd504b4874b9ec3e0fbff49a25cb46f (patch)
tree29b59d97d8b8ce8ee00227c41227d824d6694efa /OpenSim/Region/ScriptEngine/Shared/Api
parentUse GetInventoryItem() in llRezAtRoot rather than iterating through a cloned ... (diff)
downloadopensim-SC-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.zip
opensim-SC-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.tar.gz
opensim-SC-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.tar.bz2
opensim-SC-951b45b80fd504b4874b9ec3e0fbff49a25cb46f.tar.xz
Add OSSL function osForceAttachToAvatarFromInventory()
This works like osForceAttachToAvatar() but allows an object to be directly specified from the script object's inventory rather than forcing it to be rezzed in the scene first. Still only attaches objects to the owner of the script. This allows one to bypass the complicated co-ordination of first rezzing objects in the scene before attaching them. Threat level high.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs54
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
3 files changed, 65 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7fa25f5..fa9364d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
126 [Serializable] 126 [Serializable]
127 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi 127 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
128 { 128 {
129// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 129 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
130 130
131 public const string GridInfoServiceConfigSectionName = "GridInfoService"; 131 public const string GridInfoServiceConfigSectionName = "GridInfoService";
132 132
@@ -3151,6 +3151,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3151 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); 3151 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3152 } 3152 }
3153 3153
3154 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
3155 {
3156 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory");
3157
3158 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3159
3160 if (attachmentsModule == null)
3161 return;
3162
3163 m_host.AddScriptLPS(1);
3164
3165 InitLSL();
3166
3167 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
3168
3169 if (item == null)
3170 {
3171 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName));
3172 throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName));
3173 }
3174
3175 if (item.InvType != (int)InventoryType.Object)
3176 {
3177 // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set
3178 // up the api reference.
3179 if (m_LSL_Api != null)
3180 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName));
3181
3182 throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName));
3183
3184 return;
3185 }
3186
3187 ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
3188
3189 if (sp == null)
3190 return;
3191
3192 InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID);
3193
3194 if (newItem == null)
3195 {
3196 m_log.ErrorFormat(
3197 "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}",
3198 itemName, m_host.Name, attachmentPoint, World.Name);
3199
3200 return;
3201 }
3202
3203 attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint);
3204 }
3205
3154 public void osForceDetachFromAvatar() 3206 public void osForceDetachFromAvatar()
3155 { 3207 {
3156 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); 3208 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index e92518d..a8335aa 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -107,6 +107,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
107 void osForceAttachToAvatar(int attachment); 107 void osForceAttachToAvatar(int attachment);
108 108
109 /// <summary> 109 /// <summary>
110 /// Attach the inventory item in the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
111 /// </summary>
112 /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param>
113 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
114 void osForceAttachToAvatarFromInventory(string itemName, int attachment);
115
116 /// <summary>
110 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH 117 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
111 /// </summary> 118 /// </summary>
112 /// <remarks>Nothing happens if the object is not attached.</remarks> 119 /// <remarks>Nothing happens if the object is not attached.</remarks>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index d230662..500ed96 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -296,6 +296,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); 296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 } 297 }
298 298
299 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
300 {
301 m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint);
302 }
303
299 public void osForceDetachFromAvatar() 304 public void osForceDetachFromAvatar()
300 { 305 {
301 m_OSSL_Functions.osForceDetachFromAvatar(); 306 m_OSSL_Functions.osForceDetachFromAvatar();