Talk:OsGetGender

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Equivalent in pure LSL: new section)
 
m (Equivalent in pure LSL: added extra check for empty list)
 
Line 7: Line 7:
 
{
 
{
 
     list out = llGetObjectDetails(avatar, [OBJECT_BODY_SHAPE_TYPE]);
 
     list out = llGetObjectDetails(avatar, [OBJECT_BODY_SHAPE_TYPE]);
 +
    if (out == []) return "unknown";
 +
 
     float shape = llList2Float(out, 0);
 
     float shape = llList2Float(out, 0);
 
     if (shape == -1.0)
 
     if (shape == -1.0)
Line 21: Line 23:
 
</source>
 
</source>
  
See the [https://wiki.secondlife.com/wiki/OBJECT_BODY_SHAPE_TYPE LSL Wiki].
+
See also the example on the [https://wiki.secondlife.com/wiki/OBJECT_BODY_SHAPE_TYPE LSL Wiki] page.
  
 
— [[User:Gwyneth Llewelyn|Gwyneth Llewelyn]] ([[User talk:Gwyneth Llewelyn|talk]]) 15:43, 17 May 2023 (PDT)
 
— [[User:Gwyneth Llewelyn|Gwyneth Llewelyn]] ([[User talk:Gwyneth Llewelyn|talk]]) 15:43, 17 May 2023 (PDT)

Latest revision as of 14:47, 17 May 2023

[edit] Equivalent in pure LSL

In pure LSL this can be accomplished with:

string getGender(key id)
{
    list out = llGetObjectDetails(avatar, [OBJECT_BODY_SHAPE_TYPE]);
    if (out == []) return "unknown";
 
    float shape = llList2Float(out, 0);
    if (shape == -1.0)
    {
        // avatar out of range, invalid UUID, or id is not an avatar:
        return "unknown";
    }
    if (shape < 0.5)
    {
        return "female";
    }
    return "male";
}

See also the example on the LSL Wiki page.

Gwyneth Llewelyn (talk) 15:43, 17 May 2023 (PDT)

Personal tools
General
About This Wiki