diff options
author | Justin Clark-Casey (justincc) | 2012-07-05 00:05:06 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-05 00:05:06 +0100 |
commit | 951b45b80fd504b4874b9ec3e0fbff49a25cb46f (patch) | |
tree | 29b59d97d8b8ce8ee00227c41227d824d6694efa /OpenSim/Region/ScriptEngine/Shared/Api/Implementation | |
parent | Use GetInventoryItem() in llRezAtRoot rather than iterating through a cloned ... (diff) | |
download | opensim-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/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 54 |
1 files changed, 53 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"); |