Jump to content

llRequestUserKey and llKey2Name, There and Back Again


Moon Corrigible
 Share

You are about to reply to a thread that has been inactive for 1789 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I can not for the life of me figure out what I am doing wrong here.   Why doesn't this work?

 

key name_key_query;

default
{
    state_entry()
    {
        llListen(1, "", NULL_KEY, "");
    }
    
    listen(integer channel, string name, key id, string message)
    {
        name_key_query = llRequestUserKey(message);
    }
    
    dataserver(key queryid, string data)
    {
        if(name_key_query == queryid)
        {
            llSay(0, "That key is: " + data);
            key handle = (key)data;
            llSay(0, "So the name is: " + llKey2Name(handle));
            key other_way = llList2Key([data], 0);
            llSay(0, "or perhaps this will work: " + llKey2Name(other_way));
        }
    }
}

 

These are the results I get:

[08:04] Object: That key is: f70d9f76-1d94-4fd9-9535-ab9d3bab51ba
[08:04] Object: So the name is:
[08:04] Object: or perhaps this will work:

I get the correct numbers for the key just fine and dandy but I can not get llKey2Name to give me the name back again.  Granted I could just store everything as a strided list, but that seems inelegant at best.

 

Anyone have any idea what I'm missing?  Thanks in advance!!

Link to comment
Share on other sites

Holy macaroni that worked:

 

key name_key_query;
key back_again;

default
{
    state_entry()
    {
        llListen(1, "", NULL_KEY, "");
    }
    
    listen(integer channel, string name, key id, string message)
    {
        name_key_query = llRequestUserKey(message);
    }
    
    dataserver(key queryid, string data)
    {
        if(name_key_query == queryid)
        {
            llSay(0, "That key is: " + data);
            back_again = llRequestAgentData(data, DATA_NAME);
        }
        else if(back_again == queryid)
        {
            llSay(0, "So the name is: " + data);
        }
    }
}

[08:33] Object: That key is: f70d9f76-1d94-4fd9-9535-ab9d3bab51ba
[08:33] Object: So the name is: Moon Corrigible

 

I still don't understand why llKey2Name didn't work but I'll take my victories where I can get them!

 

Edited by Moon Corrigible
Link to comment
Share on other sites

5 minutes ago, Moon Corrigible said:

I still don't understand why llKey2Name didn't work but I'll take my victories where I can get them!

You should read the wiki more often, because it explains the pitfalls of each function in most cases:

Quote

The key 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).

 

Link to comment
Share on other sites

llKey2Name asks the simulator for the information. The simulator only keeps information that's relevant to it right now, and maybe for a just bit longer until it gets purged for not being immediately relevant. The llRequest* functions ask the database for the information. This is always available, but takes longer to access, hence the use of callback functions.

Depending on the context, using the forms from Viewer URI Name Space may be a useful option, for example:

"User secondlife:///app/agent/" + (string) llDetectedKey (0) + "/inspect was detected."

  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1789 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...