Profile Greeter

// tweaked by Gwyneth Llewelyn to use sensors

string RESIDENT_URL = "http://world.secondlife.com/resident/";
key nameKey;
vector curPos;

default
{

state_entry()
{
    llSetTexture(TEXTURE_BLANK, ALL_SIDES);
    nameKey = llGetOwner();
    llHTTPRequest(RESIDENT_URL + (string)nameKey,[HTTP_METHOD,"GET"],"");

    // save current location
    curPos = llGetPos();

    // start sensors

    llSensorRepeat("", NULL_KEY, AGENT, 20.0, TWO_PI, 10);
}

sensor(integer total_number)
{
    vector current = llDetectedPos(0) -curPos;
    vector nearest = current;
    integer i;
    nameKey = llDetectedKey(0);

    for (i = 1; i < total_number; i++)
    {
        current = llDetectedPos(i);

        if (llVecDist(current, curPos) < llVecDist(nearest, curPos))
        {
            nearest = current;
            nameKey = llDetectedKey(i);
        }
    }

    llHTTPRequest(RESIDENT_URL + (string)nameKey,[HTTP_METHOD,"GET"],"");
}

on_rez(integer start_param)
{
    llResetScript();
}

changed(integer what)
{
    if ((what & CHANGED_SHAPE) || (what & CHANGED_SCALE))
        llResetScript();
}

http_response(key request_id,integer status, list metadata, string body)
{
    if (llSubStringIndex(body, NULL_KEY) == -1)
    {
        integer start_of_UUID = llSubStringIndex(body,"<meta name=\"imageid\" content=\"") + llStringLength("<meta name=\"imageid\" content=\"");
        string profile_pic = llGetSubString(body, start_of_UUID, start_of_UUID + 35);

        llSetTexture((key)profile_pic, ALL_SIDES);
    }
    else
    {
        llWhisper(0, "You have no profile picture");
        llSetTexture(TEXTURE_BLANK, ALL_SIDES);
    }
}

} // end default
Print Friendly, PDF & Email
| ← Previous | |
%d bloggers like this: