diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 45 |
1 files changed, 45 insertions, 0 deletions
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 | |||
2978 | 2978 | ||
2979 | return SaveAppearanceToNotecard(avatarId, notecard); | 2979 | return SaveAppearanceToNotecard(avatarId, notecard); |
2980 | } | 2980 | } |
2981 | |||
2982 | /// <summary> | ||
2983 | /// Get the gender as specified in avatar appearance for a given avatar key | ||
2984 | /// </summary> | ||
2985 | /// <param name="rawAvatarId"></param> | ||
2986 | /// <returns>"male" or "female" or "unknown"</returns> | ||
2987 | public LSL_String osGetGender(LSL_Key rawAvatarId) | ||
2988 | { | ||
2989 | CheckThreatLevel(ThreatLevel.None, "osGetGender"); | ||
2990 | m_host.AddScriptLPS(1); | ||
2991 | |||
2992 | UUID avatarId; | ||
2993 | if (!UUID.TryParse(rawAvatarId, out avatarId)) | ||
2994 | return new LSL_String("unknown"); | ||
2995 | |||
2996 | ScenePresence sp = World.GetScenePresence(avatarId); | ||
2997 | |||
2998 | if (sp == null || sp.IsChildAgent || sp.Appearance == null || sp.Appearance.VisualParams == null) | ||
2999 | return new LSL_String("unknown"); | ||
3000 | |||
3001 | // find the index of "shape" parameter "male" | ||
3002 | int vpShapeMaleIndex = 0; | ||
3003 | bool indexFound = false; | ||
3004 | VisualParam param = new VisualParam(); | ||
3005 | foreach(var vpEntry in VisualParams.Params) | ||
3006 | { | ||
3007 | param = vpEntry.Value; | ||
3008 | if (param.Name == "male" && param.Wearable == "shape") | ||
3009 | { | ||
3010 | indexFound = true; | ||
3011 | break; | ||
3012 | } | ||
3013 | |||
3014 | if (param.Group == 0) | ||
3015 | vpShapeMaleIndex++; | ||
3016 | } | ||
3017 | |||
3018 | if (!indexFound) | ||
3019 | return new LSL_String("unknown"); | ||
3020 | |||
3021 | float vpShapeMale = Utils.ByteToFloat(sp.Appearance.VisualParams[vpShapeMaleIndex], param.MinValue, param.MaxValue); | ||
3022 | |||
3023 | bool isMale = vpShapeMale > 0.5f; | ||
3024 | return new LSL_String(isMale ? "male" : "female"); | ||
3025 | } | ||
2981 | 3026 | ||
2982 | /// <summary> | 3027 | /// <summary> |
2983 | /// Get current region's map texture UUID | 3028 | /// Get current region's map texture UUID |