Find Avatar Key
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Find Avatar Key
Explores UUID of avatar whose name is said in local chat or who touches the prim. Uses Name2Key code published in LSL Library.
Requirements:
- Place this script into a single prim and decorate to taste.
Operation:
- No special instructions. It operates stand alone once installed.
<lsl> // Find Avatar Key Script // by Huney Jewell // uses Name2Key code published in LSL Library // // Put in single prim // Explores UUID of avatar whose name is said in local chat or who touches the prim // LL Search engine sometimes returns wrong profile, hence lookup may fail. // Then the only method to explore the key is by touching the prim //
// GLOBALS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// System settings - Do Not Change Anything Below!
string proxy = "http://66.196.80.202/babelfish/translate_url_content?&intl=us&lp=fr_en&trurl="; string search = "http://search.secondlife.com/client_search.php?session=00000000-0000-0000-0000-000000000000&q="; string result = "secondlife:///app/agent/"; string profile = "Resident profiles"; string notfound = "There were no matches for ";
list requests = [];
// CODE ENTRY //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default {
on_rez(integer i) { llResetScript(); }
state_entry()
{
llSay(0, "Ready. Say \"/1 firstname lastname\" or touch me");
llListen(1, "", "", "");
}
touch_start(integer total_number)
{
integer i = 0;
for (; i < total_number; ++i)
{
llSay(0, llDetectedName(i) + " = " + (string)llDetectedKey(i));
}
}
listen(integer c, string n, key i, string msg)
{
llSay(0,"Requesting key for " + msg);
if(llListFindList(requests,[msg]) == -1) {
list Args=llParseString2List(msg, [" "], []);
string FirstName = llList2String(Args, 0);
string LastName = llList2String(Args, 1);
string url = proxy + llEscapeURL(search) + FirstName + "%2520" + LastName;;
key id = llHTTPRequest(url, [], "");
requests += [(string)id,msg];
}
}
http_response(key request_id, integer status, list metadata, string body)
{
integer p = llListFindList(requests,[(string)request_id]);
if (p != -1) {
string name = llList2String(requests,p+1);
integer find = llSubStringIndex(body,result);
if(find == -1) {
find = llSubStringIndex(body,notfound);
if(find == -1)
llSay(0,"Error with lookup!");
else
llSay(0," Lookup '" + name + "' failed: Not found.");
}
else
{
find += llStringLength(result);
string avKey = llGetSubString(body,find,find+35);
integer namePos = llSubStringIndex(body,profile)+18;
string foundName = llGetSubString(body, namePos+1, namePos + llSubStringIndex(llGetSubString(body,namePos+1, llStringLength(body)-1),"<"));
if(llToLower(name) == llToLower(foundName))
llSay(0,foundName + " = " + avKey);
else
llSay(0," Lookup '" + name + "' failed: Wrong found.");
}
requests = llDeleteSubList(requests,p,p+1);
}
}
} </lsl>