mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
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.
This commit is contained in:
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
[Serializable]
|
||||
public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public const string GridInfoServiceConfigSectionName = "GridInfoService";
|
||||
|
||||
@@ -3151,6 +3151,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
|
||||
}
|
||||
|
||||
public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory");
|
||||
|
||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||
|
||||
if (attachmentsModule == null)
|
||||
return;
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
InitLSL();
|
||||
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName));
|
||||
throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName));
|
||||
}
|
||||
|
||||
if (item.InvType != (int)InventoryType.Object)
|
||||
{
|
||||
// FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set
|
||||
// up the api reference.
|
||||
if (m_LSL_Api != null)
|
||||
((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName));
|
||||
|
||||
throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
|
||||
|
||||
if (sp == null)
|
||||
return;
|
||||
|
||||
InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID);
|
||||
|
||||
if (newItem == null)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}",
|
||||
itemName, m_host.Name, attachmentPoint, World.Name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint);
|
||||
}
|
||||
|
||||
public void osForceDetachFromAvatar()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
|
||||
|
||||
Reference in New Issue
Block a user