From 5d3c327e939be9e134c1ca8853f653d9b7d080e2 Mon Sep 17 00:00:00 2001
From: dahlia
Date: Fri, 29 May 2015 23:02:12 -0700
Subject: Add a new os function "osGetGender()"
---
.../Shared/Api/Implementation/OSSL_Api.cs | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index b0b0baa..517a9d9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2978,6 +2978,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return SaveAppearanceToNotecard(avatarId, notecard);
}
+
+ ///
+ /// Get the gender as specified in avatar appearance for a given avatar key
+ ///
+ ///
+ /// "male" or "female" or "unknown"
+ public LSL_String osGetGender(LSL_Key rawAvatarId)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osGetGender");
+ m_host.AddScriptLPS(1);
+
+ UUID avatarId;
+ if (!UUID.TryParse(rawAvatarId, out avatarId))
+ return new LSL_String("unknown");
+
+ ScenePresence sp = World.GetScenePresence(avatarId);
+
+ if (sp == null || sp.IsChildAgent || sp.Appearance == null || sp.Appearance.VisualParams == null)
+ return new LSL_String("unknown");
+
+ // find the index of "shape" parameter "male"
+ int vpShapeMaleIndex = 0;
+ bool indexFound = false;
+ VisualParam param = new VisualParam();
+ foreach(var vpEntry in VisualParams.Params)
+ {
+ param = vpEntry.Value;
+ if (param.Name == "male" && param.Wearable == "shape")
+ {
+ indexFound = true;
+ break;
+ }
+
+ if (param.Group == 0)
+ vpShapeMaleIndex++;
+ }
+
+ if (!indexFound)
+ return new LSL_String("unknown");
+
+ float vpShapeMale = Utils.ByteToFloat(sp.Appearance.VisualParams[vpShapeMaleIndex], param.MinValue, param.MaxValue);
+
+ bool isMale = vpShapeMale > 0.5f;
+ return new LSL_String(isMale ? "male" : "female");
+ }
///
/// Get current region's map texture UUID
--
cgit v1.1