Jump to content
Rider Linden

New script functions for LSL

Recommended Posts

Hi there,

I'd like to take a moment to announce two new script function that we here at the lab are just putting into testing on the Beta Grid(Aditi) and that will roll out to the main grid in the coming weeks.

llName2Key and llRequestUserKey.  These functions will provide the UUID of a named avatar.  llName2Key only works for agents that are either in the region that the script is running on, llRequestUserKey will work for any agent on the grid.

Documentation on these functions is on the Second Life wiki. Here: llName2Key  and here: llRequestUserKey.

They are available for testing on the beta grid (Aditi) in the following regions: Sylveon, Umbreon, Leafeon and Mystic Lane

 

Sample Usage
integer chat_handle = 0;

list events;
integer STRIDE = 2;

default
{
    state_entry()
    {
        llSetTextureAnim(ANIM_ON|LOOP, ALL_SIDES, 5, 5, 0, 23, 20.0);
        chat_handle = llListen(1, "", llGetOwner(), "");
    }

    listen( integer channel, string name, key id, string message)
    {
        llSay(0, "Checking for \"" + message + "\"");
        llSay(0, "llName2Key = " + (string)llName2Key(message));

        if (llGetOwner() != id)
        {
            llSay(0, "No dataserver lookup for you!");
            return;
        }
        
        events += [ llRequestUserKey(message), message ];
    }

    
    dataserver(key request_id, string data)
    {
        integer index = llListFindList(events, [ request_id] );

        if (~index )
        { 
            string name = llList2String(events, index + 1);
            llSay(0, "Dataserver \"" + name + "\" = " + data );
 
            events = llDeleteSubList(events, index, index + STRIDE - 1);
        }
    }

}
 

A quick afterward for people who were at the user group meetings: Please note the name change.

Edited by Rider Linden
  • Like 3
  • Thanks 3

Share this post


Link to post
Share on other sites

copy / pasted this...

llRequestUserKey  works good,

llName2Key gives an error... "name not defined within scope"

@aditi - Sylveon - secondlife://util.aditi.lindenlab.com/secondlife/Sylveon/131/132/23

 

on RequestUserKey wiki page.. typo:  owner_name_query  should be name_key_query

Edited by Xiija
  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, Xiija said:

llName2Key gives an error... "name not defined within scope"

I'm still updating the region.   (give me 5 more minutes.)

Edited by Rider Linden

Share this post


Link to post
Share on other sites

Somethiing I noticed today. I first tried llName2Key on an agent I knew wasn't in the region, as it's an old friend that hasn't been online in years. Of course it returned NULL_KEY Then I used llRequestUserKey for the same name. Then when I used llName2Key again, it returned the actual UUID. Thinking maybe it just kept it in the script's memory somewhere (not as a variable) I tried it with 2 seperate scripts. Same thing, it still had the key available for another script only calling llName2Key. Decided to try again on a different name. First called llName2Key, returned NULL_KEY, seperate object and script, called llRequestUserKey, got the UUID, called llName2Key again, got uuid. I suppose the data server temporarily saves that in the sim's script memory for other scripts to be able to call it? How long? would be be of any use? How long does after an avatar leaves the sim can llName2Key return the UUID?

Share this post


Link to post
Share on other sites

Your observations are correct.  llName2Key does a fast check against the agent name cache on the simhost.  If the agent's name is not found the function returns NULL immediately. llRequestUserKey does a (potentially) longer lookup for the agent's name and may hit the user database in the process. When llRequestUserKey gets a response the name and UUID are added to the name cache for the region, so a subsequent llName2Key will in fact find a valid response to return.  

You should make no assumptions about the length of time a user's record will remain cached other than it will be kept as long as the agent is physically in the region, and for a short time after they have left. It will also be cached briefly following a call to llRequestUserKey.

Note: Because of this behavior, llName2Key is not a reliable way to determine if a user is actually present in the region. 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 5/21/2018 at 4:14 PM, Lucia Nightfire said:

Rider, can you please update the wiki page for llName2Key() outlining that behavior? Thanks.

Also, this caveat on the llKey2Name page should probably be removed:

  • 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.
  • Like 2

Share this post


Link to post
Share on other sites

I just want to say thanks for this to the SL devs behind this.

It's a much-needed function set. I'm pretty sure many creators are very pleased they don't have to communicate with and rely on third-party username/UUID databases (some with shady reputations) anymore.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 6/4/2018 at 6:25 PM, Arron Rainfall said:

Also, this caveat on the llKey2Name page should probably be removed:

  • 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.

Done.  Links to third-party services have been retained in the Notes section of that page for those who still need that information.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...