From a858c5daee64223355de04b77746142be0f5795f Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Sat, 1 Sep 2012 02:39:49 +0100
Subject: implementing a function to get the number of attachments worn
---
.../Shared/Api/Implementation/OSSL_Api.cs | 38 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 10 ++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 7 ++++
3 files changed, 55 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e245684..57f1e65 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3313,6 +3313,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
((LSL_Api)m_LSL_Api).DetachFromAvatar();
}
+ public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments");
+
+ m_host.AddScriptLPS(1);
+
+ UUID targetUUID;
+ ScenePresence target;
+ LSL_List resp = new LSL_List();
+
+ if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
+ {
+ foreach (object point in attachmentPoints.Data)
+ {
+ LSL_Integer ipoint = new LSL_Integer(
+ (point is LSL_Integer || point is int || point is uint) ?
+ (int)point :
+ 0
+ );
+ resp.Add(ipoint);
+ if (ipoint == 0)
+ {
+ // indicates zero attachments
+ resp.Add(new LSL_Integer(0));
+ }
+ else
+ {
+ // gets the number of attachments on the attachment point
+ resp.Add(new LSL_Integer(target.GetAttachments((uint)ipoint).Count));
+ }
+ }
+ }
+
+ return resp;
+ }
+
+ #endregion
+
///
/// Checks if thing is a UUID.
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 06729ab..6db6443 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -192,6 +192,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// Nothing happens if the object is not attached.
void osForceDetachFromAvatar();
+ ///
+ /// Returns a strided list of the specified attachment points and the number of attachments on those points.
+ ///
+ /// avatar UUID
+ /// list of ATTACH_* constants
+ ///
+ LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
+
+ #endregion
+
//texture draw functions
string osMovePen(string drawList, int x, int y);
string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index ba1ade2..230c378 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -311,6 +311,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osForceDetachFromAvatar();
}
+ public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
+ {
+ return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints);
+ }
+
+ #endregion
+
// Texture Draw functions
public string osMovePen(string drawList, int x, int y)
--
cgit v1.1