Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why no Agent name on sensor detect?

Dire Lobo
Registered User
Join date: 20 Dec 2005
Posts: 47
04-04-2006 09:40
Hey all,

In this code fragment a sensor event is raised and I call llDetectedKey(0) and get a valid key for an agent (me for example).

But when I call llKey2Name() I get an empty string. Was up?


key agentKey;
string agentName;

sensor(integer total_number)
{
for ( i = 0; i < total_number; i++ )
{
agentKey = llDetectedKey(i);
agentName == llKey2Name(agentKey);

llSay(0, "Agent - UID: " + (string) agentKey + " Name: " + agentName);

Output from llSay() shows a proper key but no name. I have used llKey2Name in other cases (not during a sensor event) and it has worked. But not here.

Anyone know why? TIA.
Kairen Overdrive
Registered User
Join date: 12 Jul 2005
Posts: 38
04-04-2006 09:56
For llKey2Name to work the agent must be in the same sim.

Try llDetectedName(i);
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-04-2006 09:58
CODE
 agentName == llKey2Name(agentKey);


needs to be

CODE
 agentName = llKey2Name(agentKey);


Single = for assignment, double == for comparison.

And you can use llDetectedName(i) directly, you don't need to go through the two steps of llDetectedKey followed by llKey2Name.
Michael Martinez
Don't poke me!
Join date: 28 Jul 2004
Posts: 515
04-04-2006 10:00
llKey2Name only works for avies in the same sim, so will get nothing if not in same sim.

Use Dataserver for that information if online/offline same sim, does not matter..

http://secondlife.com/badgeo/wakka.php?wakka=llRequestAgentData
_____________________
There are no significant bugs in our released software that any significant number of users want fixed. (Bill Gates)
Dire Lobo
Registered User
Join date: 20 Dec 2005
Posts: 47
04-04-2006 10:47
From: Ziggy Puff
CODE
 agentName == llKey2Name(agentKey);


needs to be

CODE
 agentName = llKey2Name(agentKey);


Single = for assignment, double == for comparison.

And you can use llDetectedName(i) directly, you don't need to go through the two steps of llDetectedKey followed by llKey2Name.


DUH! Of course I copied that right out of a prim and in fact I had the double equal as shown in this thread. Double DUH! Never noticed it. Stared at it for 10 minutes.

In this case I need the agent's name and key (both) otherwise I would just call llDetectedName(), but I could see how you might assume I was a bleeding idiot after the double equal screw up! Ha ha.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
04-04-2006 10:54
I'm not quite getting that - you can get the name with llDetectedName, and the key with llDetectedKey, what's the problem with using both if you want both?
Dire Lobo
Registered User
Join date: 20 Dec 2005
Posts: 47
04-04-2006 20:36
No problem, per se. But intuitively it seems like doing a lookup on the key to get the name should be less expensive then calling llDetectedName. Presumably LL refers internally to avatars as agents using the key. I suspect the body of llDetectedName contains a call to llDetectedKey and then a call to llKey2Name - that would make sense and thus why incur an additional call to llDetectedKey considering I already have the key. That is my thinking. Perhaps I am completely wrong about the implementation of llDetectedName but there you have it.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
04-04-2006 20:51
From: Dire Lobo

string llDetectedName(int i) {
return llKey2Name(llDetectedKey(i));
}


Not necessarily. I think internally, the llDetected functions refer to an array (which the integer indexes into) of structs of data (name, key, position, rotation, &c) that store information about the detected stuff. (I'm probably wrong.) What llDetectedName offers you is the capability to retreve the name of an object/avatar that is currently (or has moved) outside the simulator of the sensing object. (Sensors occasionally pick up things outside the sim, when their range extends over a sim border.)
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm