llKey2Name
string llKey2Name(key id// UUID of the target avatar or prim in the same region.
);- Returns
string- Energy
- 10
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.
Returns a string that is the legacy name of the prim or avatar specified by id.
string result = llKey2Name(NULL_KEY);Caveats
Section titled “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
llGetObjectDetailsto avoid this problem. - To get around the “avatar must be present” limitation, you can use the
llRequestAgentDatafunction and thedataserverevent 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, usellRequestUserKey, which triggers adataserverevent. - 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
llSensorand the Mini-Map. This fact can be used as the basis of a Ghost Detector script. - Unlike the related functions
llGetUsernameandllRequestUsername, 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
Section titled “Examples”Example 1
5 collapsed lines
// 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); }}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:
- W-Hat name2key (last names replaced with the Resident word for the Usernames)
- KDC name2key
Dead Name2Key Databases:
- Kubwa name2key (Bot based name2key Database; Supports: Legacy and Username formats; Shows related names; SSL support.) (Appears to be gone as of Apr 2013 [Reports Error 404])
http://wiki.apez.biz/Development (web-service API functions getAvatarKey and getAvatarName)(Apez seems to be gone ? - May 2011)- ~~http://www.libsecondlife.org/protocol/index.php/Name2key~~(Appears to be gone as of Apr 2008, but search for name2key on that site for more information)
- ~~http://www.ulrikasheim.org/tools/name2key.html~~(Appears to be gone as of Apr 2008)
DB4MV name2key (Name2Key Database for Avatars (Legacy Names,Usernames, and Display Names, GroupNames and Keys, LSL API)(Currently listed as non-existant by host)
Name2Key Libraries:
History
Section titled “History”Added in SL 0.4.0
Known issues
Section titled “Known issues”From the issue templates included by the wiki article:
- SVC-215 (nf): llRequestAgentKey() (llName2Key())
- SVC-4170 (bug): llKey2Name returns avatar names with double space between first and last (sometimes)
- SVC-3935 (bug): llKey2Name returns text “(Loading…)” instead of empty string or avatar name
See also
Section titled “See also”Functions
Section titled “Functions”llGetUsernamellGetDisplayNamellGetObjectDetailsllRequestAgentData— Uses thedataserverto request avatar information
Articles
Section titled “Articles”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.