Don't click here unless you want to be banned.

LSL Wiki : llKey2Name

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl836.us.archive.org
string llKey2Name(key id)

If the object or agent identified by the key id is in the same simulator as the object containing the script, this function returns their name. Otherwise, an empty string ("") is returned. This can be misleading, because it cannot be distinguished from an object with an empty name (""). See llGetObjectDetails for a better function.

Only works on rezzed objects and avatars. Scripts, animations, and textures will return an empty string ("").

See llRequestAgentData for a (much slower) way to use the dataserver to get the name of an agent even outside the sim or offline.

Note: there is no llName2Key function. To get a key from a name, use sensors or touch events and the llDetected* functions.

Alternatively, you can use the following external sources for llName2Key functionality, in alphabetic order:
Currently unavailable sources:

Note: This function works if someone can see the sim from an adjacent sim. V1.9

This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Key
Comments [Hide comments/form]
I have found that this function could be used as a "hack" to determine if a certain agent is in the same sim as the script. It is basically "sensor-free" and even sidesteps the 96m limit for sensors. Of course you would need to know the key of the agent first, but that is easily obtainable.
-- CorSter (2006-01-12 10:54:38)
I have a texture in a child prim's inventory. The script in the root prim receive the texture id from the child prim. I have full permissions on this texture so the script can set the texture on the prim itself.
Now I need the name of the texture, but when I call llKey2Name(textureId) i get "".
Is there a way to get this texture name outside of the containing prim?
-- RaffaelePirandello (2006-01-26 14:26:23)
what part of " object or agent identified by the key id " don't you get, it only works on agent and object keys. Meaning it's the key of an agent or object.
-- BlindWanderer (2006-01-26 16:39:52)
mah messing around concluded that llKey2Name does not work for prims in a linked set... might b handy to know.
-- LikeKookies (2006-05-07 14:48:11)
forgot to add.. if someone does find a way to get a child prim's name trough linked messages other than having to send it over, do tell
-- LikeKookies (2006-05-07 14:53:49)
llGetLinkName does that, LikeKookies. Just pass it the link number to get the name of.

In other news, it appears that using llKey2Name as a same-sim check for agents won't work consistently, as of 1.9.0. Or, at least, not for a few minutes after the agent leaves the sim, because the results seem to be cached, or retrievable from neighboring sims. I used the following snippet, then left the sim, and continued to recieve IMs with my name, for several minutes, until I teleported two sims away.

default{
state_entry(){
while(TRUE){
llInstantMessage(llGetOwner(),llKey2Name(llGetOwner()));
llSleep(15.0);
}
}
} (Forgot to include my sleep, in the first time I posted this. >_> <_<)
-- SchizzySapeur (2006-05-20 23:45:12)
I used llKey2Name in a weapon I am scripting to return the name of the owner in conjunction with llOwnerSay. I post this simply because I spent about 2 hours trying to figure out how to get it to say the name of the owner in the message from the object and I am sure there are other people out there looking to do the same thing so hopefully this will be of use to others.

string name = llKey2Name(llGetOwner());
llOwnerSay("Now weilded by " + name);

Change the message in "" to whatever you want it to say and it will return that message followed by the name of the object owner. I hope that is clear enough and helps others that are trying to acheive the same outcome as I was.
-- TaHeTen (2007-01-01 23:52:34)
ill just post this example:

string sim;
vector pos;
string owner;
default
{
touch_start(integer count)
{
sim = llGetRegionName();
pos = llGetPos();
owner = llKey2Name(llGetOwner());
llSay(0, "" + (string)owner + " is at " + (string)sim + " at " + (string)pos");
}
}

Returns "OWNERS NAME is at SIM at POSITION".
-- Turnni1 (2007-01-15 02:36:22)
That example gives the position of the object, not the position of the owner.
-- ool-18bf68ca.dyn.optonline.net (2007-06-14 15:29:51)
Here's my simple mod of the default script to show how to use this in an inefficient "when touched by owner" script:

default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}

touch_start(integer total_number)
{
If the one who touched this is the owner, execute what's inside the brackets.
if ( llDetectedName(0) == llKey2Name(llGetOwner()) ) {
llSay(0, "You are the owner.");
}
end-if
Everybody who touches sees this. Consider if-then-else structure instead
llSay(0, "Touched.");
}
end-touch-start
}
-- c-71-225-108-196.hsd1.pa.comcast.net (2007-08-27 19:00:22)
Attach a comment to this page: