Difference between revisions of "LlKey2Name"

From Second Life Wiki
Jump to navigation Jump to search
m
m (Added name formatting caveat)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{Issues/SVC-215}}{{Issues/SVC-4170}}{{Issues/SVC-3935}}{{LSL_Function/uuid|id|sim=*}}
|inject-2={{Issues/SVC-215}}{{Issues/SVC-4170}}{{Issues/SVC-3935}}{{LSL_Function/uuid|id|sim=*|group=}}
|func_id=210|func_sleep=0.0|func_energy=10.0
|func_id=210|func_sleep=0.0|func_energy=10.0
|sort=Key2Name|func=llKey2Name
|sort=Key2Name|func=llKey2Name
Line 11: Line 11:
|caveats=* It is difficult to tell the difference between a prim that has a name that is an empty string and a prim that is not in the sim, or because an invalid key was specified. Use [[llGetObjectDetails]] to avoid this problem.
|caveats=* It is difficult to tell the difference between a prim that has a name that is an empty string and a prim that is not in the sim, or because an invalid key was specified. Use [[llGetObjectDetails]] to avoid this problem.
* To get around the "avatar must be present" limitation, you can use the [[llRequestAgentData]] function and the [[dataserver]] event to obtain the avatar's name from a key.
* To get around the "avatar must be present" limitation, you can use the [[llRequestAgentData]] function and the [[dataserver]] event to obtain the avatar's name from a key.
* There is no opposite function ([[llName2Key]]) available. However, there are third-party websites which can be queried using the [[llHTTPRequest]] function and the [[http_response]] event.
* The opposite function ([[llName2Key]]) can be used to find the user key associated with an avatar in the same region. To find the user key of an avatar anywhere on the grid, use [[llRequestUserKey]], which triggers a [[dataserver]] event.
* If an avatar is "ghosted" (which occasionally happens due to a longstanding server bug), an empty string is returned even though the avatar is seemingly present and shows up in [[llSensor]] and the [[Mini-Map]].  This fact can be used as the basis of a [[Ghost Detector]] script.
* If an avatar is "ghosted" (which occasionally happens due to a longstanding server bug), an empty string is returned even though the avatar is seemingly present and shows up in [[llSensor]] and the [[Mini-Map]].  This fact can be used as the basis of a [[Ghost Detector]] script.
* Unlike the related functions [[llGetUsername]] and [[llRequestUsername]], this function returns a 'nice' name in proper case and - if applicable - with a space, e.g. "Peter Stindberg", instead of "peter.stindberg" (or "Josh" instead of "josh.resident") as returned by the other two functions.
|constants
|constants
|examples=
|examples=
<lsl>
<syntaxhighlight lang="lsl2">
// Best viewed in Chat History (ctrl-h)
// Best viewed in Chat History (ctrl-h)


Line 27: Line 28:
         string detectedName = llDetectedName(0);
         string detectedName = llDetectedName(0);


        // PUBLIC_CHANNEL has the integer value 0
         llSay(0, "llKey2Name: " + name
         llSay(PUBLIC_CHANNEL,
            "llKey2Name: " + name
             + "\nllDetectedName: " + detectedName);
             + "\nllDetectedName: " + detectedName);
     }
     }
Line 40: Line 39:
         string detectedName = llDetectedName(0);
         string detectedName = llDetectedName(0);


        // PUBLIC_CHANNEL has the integer value 0
         llSay(0, "llKey2Name: " + name
         llSay(PUBLIC_CHANNEL,
            "llKey2Name: " + name
             + "\nllDetectedName: " + detectedName);
             + "\nllDetectedName: " + detectedName);
     }
     }
}
}
</lsl>
</syntaxhighlight>
|helpers
|helpers
|also_functions=
|also_functions=
Line 79: Line 76:
|cat4=Avatar/Name
|cat4=Avatar/Name
|cat5=Legacy Name
|cat5=Legacy Name
|history={{LSL Added|0.4.0|remote=http://secondlife.wikia.com/wiki/Version_0.4.0}}
|haiku={{Haiku|Numbers in machines,|Faceless, inhuman, sterile.|Bleak identities.}}
|history={{LSL Added|0.4.0|remote=http://secondlife.wikia.com/wiki/Version_0.4.0#Scripting}}  
}}
}}

Latest revision as of 10:05, 8 December 2023

Summary

Function: string llKey2Name( key id );
0.0 Forced Delay
10.0 Energy

Returns a string that is the legacy name of the prim or avatar specified by id.

• key id avatar or prim UUID that is in the same region

id must specify a valid rezzed prim or avatar key, present in or otherwise known to the sim in which the script is running, otherwise an empty string is returned. In the case of an avatar, this function will still return a valid name if the avatar is a child agent of the sim (i.e., in an adjacent sim, but presently able to see into the one the script is in), or for a short period after the avatar leaves the sim (specifically, when the client completely disconnects from the sim, either as a main or child agent).

Keys of inventory items will not work; in the case of these, use llGetInventoryName instead.

Caveats

  • It is difficult to tell the difference between a prim that has a name that is an empty string and a prim that is not in the sim, or because an invalid key was specified. Use llGetObjectDetails to avoid this problem.
  • To get around the "avatar must be present" limitation, you can use the llRequestAgentData function and the dataserver event to obtain the avatar's name from a key.
  • The opposite function (llName2Key) can be used to find the user key associated with an avatar in the same region. To find the user key of an avatar anywhere on the grid, use llRequestUserKey, which triggers a dataserver event.
  • If an avatar is "ghosted" (which occasionally happens due to a longstanding server bug), an empty string is returned even though the avatar is seemingly present and shows up in llSensor and the Mini-Map. This fact can be used as the basis of a Ghost Detector script.
  • Unlike the related functions llGetUsername and llRequestUsername, this function returns a 'nice' name in proper case and - if applicable - with a space, e.g. "Peter Stindberg", instead of "peter.stindberg" (or "Josh" instead of "josh.resident") as returned by the other two functions.

Examples

// Best viewed in Chat History (ctrl-h)

default
{
    collision_start(integer num_detected)
    {
        key id = llDetectedKey(0);
        string name = llKey2Name(id);

        string detectedName = llDetectedName(0);

        llSay(0, "llKey2Name: " + name
            + "\nllDetectedName: " + detectedName);
    }

    touch_start(integer num_detected)
    {
        key id = llDetectedKey(0);
        string name = llKey2Name(id);

        string detectedName = llDetectedName(0);

        llSay(0, "llKey2Name: " + name
            + "\nllDetectedName: " + detectedName);
    }
}

Notes

World Wide Web Consortium

  • N2K - Independent of databases or bots, this uses the W3C html2text to convert the viewer search to text and extract the key from Second Life's own services.

Active Name2Key Databases:

Dead Name2Key Databases:

Name2Key Libraries:

See Also

Functions

•  llGetUsername
•  llGetDisplayName
•  llGetObjectDetails
•  llRequestAgentData Uses the dataserver to request avatar information

Articles

•  Prim Attribute Overloading

Deep Notes

History

Footnotes

  1. ^ Early release notes were not very accurate or thorough, they sometimes included information about features added in previous releases or failed to include information about features added in that release.

Signature

function string llKey2Name( key id );

Haiku

Numbers in machines,
Faceless, inhuman, sterile.
Bleak identities.