Add a new os function "osGetGender()"

fsassets
dahlia 2015-05-29 23:02:12 -07:00
parent 0af17c9484
commit 5d3c327e93
3 changed files with 51 additions and 0 deletions

View File

@ -2978,6 +2978,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return SaveAppearanceToNotecard(avatarId, notecard); return SaveAppearanceToNotecard(avatarId, notecard);
} }
/// <summary>
/// Get the gender as specified in avatar appearance for a given avatar key
/// </summary>
/// <param name="rawAvatarId"></param>
/// <returns>"male" or "female" or "unknown"</returns>
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");
}
/// <summary> /// <summary>
/// Get current region's map texture UUID /// Get current region's map texture UUID

View File

@ -353,6 +353,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Key osOwnerSaveAppearance(string notecard); LSL_Key osOwnerSaveAppearance(string notecard);
LSL_Key osAgentSaveAppearance(key agentId, string notecard); LSL_Key osAgentSaveAppearance(key agentId, string notecard);
key osGetGender(LSL_Key rawAvatarId);
key osGetMapTexture(); key osGetMapTexture();
key osGetRegionMapTexture(string regionName); key osGetRegionMapTexture(string regionName);
LSL_List osGetRegionStats(); LSL_List osGetRegionStats();

View File

@ -870,6 +870,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
} }
} }
public string osGetGender(LSL_Key rawAvatarId)
{
return m_OSSL_Functions.osGetGender(rawAvatarId);
}
public key osGetMapTexture() public key osGetMapTexture()
{ {
return m_OSSL_Functions.osGetMapTexture(); return m_OSSL_Functions.osGetMapTexture();