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 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs') 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. /// -- cgit v1.1