Difference between revisions of "Describe Chatter"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
(Clean up code. Avoid double click issues.)
 
Line 3: Line 3:
= Introduction =
= Introduction =


Your avatar in second life is differently anonymous than yourself in real life. Any other avatar and any thing can ask what your avatar's name is, what your avatar's date-of-birth is, whether payment info is on file for your avatar, etc. The Linden servers discuss your avatar in these ways without asking you for permission and without notifying you.
Another avatar or object can ask what your avatar's name is, what your avatar's date-of-birth is, whether payment info is on file for your avatar, etc. The Linden servers will return this information without asking you for permission and without notifying you.


If you can see who is chatting, then Profile > 2nd Life will tell you things like Currently Online, Born mm/dd/yyyy, No Payment Info On File. If you don't know that, or if you can't be bothered to go there, or if you can't see who is chatting, then this script will tell you those kinds of things too.
If you can see an avatar's profile, then Profile > 2nd Life will tell you things like Currently Online, Born mm/dd/yyyy, No Payment Info On File. If you can't, then this script can tell you those kinds of things.


= Sample Results =
= Sample Results =
Line 14: Line 14:
     Name: John Doe
     Name: John Doe
     Birthday: 2007-09-23
     Birthday: 2007-09-23
     Payinfo: Has payment info on file but did not use it.
     Payinfo: Has unused payment info on file.
     Online status: Offline
     Online status: Offline
---
---
Line 36: Line 36:
string avatarOnlineStatus;
string avatarOnlineStatus;


float timeoutTimeInSeconds;
integer    gEventsReceived;               // Bit pattern of received dataserver events
list listOfWhichKeysHaveBeenReceived;
integer    gMaskName = 1;
integer    gMaskBirthday = 2;
integer    gMaskPayinfo = 4;
integer    gMaskOnline  = 8;
 
key        gToucher;


clear_cache()
clear_cache()
{
{
     timeoutTimeInSeconds = 10.0;
     gEventsReceived = 0;
 
    nameRequestId = NULL_KEY;
    birthdayRequestId = NULL_KEY;
    payinfoRequestId = NULL_KEY;
    onlineStatusRequestId = NULL_KEY;
 
     avatarLegacyName = "";
     avatarLegacyName = "";
     avatarBirthday = "";
     avatarBirthday = "";
     avatarPayinfo = "";
     avatarPayinfo = "";
     avatarOnlineStatus = "";
     avatarOnlineStatus = "";
//  yellow and opaque
    llSetText("<~!~ touch to get avatar info ~!~>", <1.0, 1.0, 0.1>, (float)TRUE);
    listOfWhichKeysHaveBeenReceived = [FALSE, FALSE, FALSE, FALSE];
}
}


initiate_requests_for_avatar_info(key avatarToRequestInfoAbout)
default
{
    nameRequestId = llRequestAgentData(avatarToRequestInfoAbout, DATA_NAME);
    birthdayRequestId = llRequestAgentData(avatarToRequestInfoAbout, DATA_BORN);
    payinfoRequestId = llRequestAgentData(avatarToRequestInfoAbout, DATA_PAYINFO);
    onlineStatusRequestId = llRequestAgentData(avatarToRequestInfoAbout, DATA_ONLINE);
}
 
process_returned_data(key query_id, string data)
{
{
     if (query_id == nameRequestId)
     state_entry()
    {
        nameRequestId = NULL_KEY;
        listOfWhichKeysHaveBeenReceived = llListReplaceList(listOfWhichKeysHaveBeenReceived,
                                            [TRUE], 0, 0);
 
        avatarLegacyName = data;
    }
    else if (query_id == birthdayRequestId)
    {
        birthdayRequestId = NULL_KEY;
        listOfWhichKeysHaveBeenReceived = llListReplaceList(listOfWhichKeysHaveBeenReceived,
                                            [TRUE], 1, 1);
 
        avatarBirthday = data;
    }
    else if (query_id == payinfoRequestId)
    {
        payinfoRequestId = NULL_KEY;
        listOfWhichKeysHaveBeenReceived = llListReplaceList(listOfWhichKeysHaveBeenReceived,
                                            [TRUE], 2, 2);
 
        avatarPayinfo = process_payinfo(data);
    }
    else if (query_id == onlineStatusRequestId)
     {
     {
         onlineStatusRequestId = NULL_KEY;
         llSetTimerEvent(0);
        listOfWhichKeysHaveBeenReceived = llListReplaceList(listOfWhichKeysHaveBeenReceived,
         //  yellow and opaque
                                            [TRUE], 3, 3);
         llSetText("<~!~ touch to get avatar info ~!~>", <1, 1, 0>, 1);
 
         integer isOnline = (integer)data;
 
         if (isOnline)
            avatarOnlineStatus = "Online";
        else
            avatarOnlineStatus = "Offline";
     }
     }
}
string process_payinfo(string data)
{
    integer payInfo = (integer)data;
    if (payInfo  & ~(PAYMENT_INFO_ON_FILE | PAYMENT_INFO_USED))
        return "- payinfo request failed -";
    integer hasPayinfo = (payInfo & PAYMENT_INFO_ON_FILE);
    integer usedPayinfo = (payInfo & PAYMENT_INFO_USED);
    if (!hasPayinfo)
//  {
        return "Has no payment info on file.";
//  }
//  else
//  {
        string payinfoOutput = "Has payment info on file ";
        if (usedPayinfo)
//      {
            payinfoOutput += "and used it.";
//      }
        else
//      {
            payinfoOutput += "but did not use it.";
//      }
        return payinfoOutput;
//  }
}
dump_result_to_local_chat()
{
    llSetTimerEvent((float)FALSE);
    if (llListStatistics(LIST_STAT_MEAN, listOfWhichKeysHaveBeenReceived) != 1.0)
//  {
        llSay(PUBLIC_CHANNEL, "Sorry, did not get a response for all requested info. Please try again!");
//  }
    else
//  {
        llSay(PUBLIC_CHANNEL, "Avatar info:"
            + "\n\tName: " + avatarLegacyName
            + "\n\tBirthday: " + avatarBirthday
            + "\n\tPayinfo: " + avatarPayinfo
            + "\n\tOnline status: " + avatarOnlineStatus);
//  }
    clear_cache();
}
default
{
     on_rez(integer start_param)
     on_rez(integer start_param)
     {
     {
Line 172: Line 72:
     }
     }


     touch_start(integer num_detected)
     touch_end(integer num_detected)
     {
     {
         key touchingAvatarKey = llDetectedKey(0);
         gToucher = llDetectedKey(0);
        state working;
    }
}


state working
{
    state_entry()
    {
        llSetText("=== please wait ===", <1, 0, 0>, 1);
         clear_cache();
         clear_cache();
         initiate_requests_for_avatar_info(touchingAvatarKey);
         nameRequestId = llRequestAgentData(gToucher, DATA_NAME);
 
        birthdayRequestId = llRequestAgentData(gToucher, DATA_BORN);
         llSetTimerEvent(timeoutTimeInSeconds);
        payinfoRequestId = llRequestAgentData(gToucher, DATA_PAYINFO);
        onlineStatusRequestId = llRequestAgentData(gToucher, DATA_ONLINE);
         llSetTimerEvent(10);
     }
     }


Line 187: Line 97:
             return;
             return;


         process_returned_data(query_id, data);
         if (query_id == nameRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskName;
            avatarLegacyName = data;
        }
        else if (query_id == birthdayRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskBirthday;
            avatarBirthday = data;
        }
        else if (query_id == payinfoRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskPayinfo;
            integer payInfo = (integer)data;
            if (payInfo  & ~(PAYMENT_INFO_ON_FILE | PAYMENT_INFO_USED))
                avatarPayinfo = "- payinfo request failed -";
 
            else
            {
                integer hasPayinfo = (payInfo & PAYMENT_INFO_ON_FILE);
                integer usedPayinfo = (payInfo & PAYMENT_INFO_USED);
                avatarPayinfo = "Has no payment info on file.";
                if (hasPayinfo)
                {
                    avatarPayinfo = "Has unused payment info on file.";
                    if (usedPayinfo)
                        avatarPayinfo =  "Has used payment info on file.";
                }
            }
        }
        else if (query_id == onlineStatusRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskOnline;
            avatarOnlineStatus = "Offline";
            if ( (integer) data )
                avatarOnlineStatus = "Online";
        }


         if (llListStatistics(LIST_STAT_MEAN, listOfWhichKeysHaveBeenReceived) == 1.0)
         if (gEventsReceived == (gMaskName | gMaskBirthday | gMaskPayinfo | gMaskOnline ) )
//      {
        {
             dump_result_to_local_chat();
             llSay(0, "Avatar info:"
//      }
                + "\n\tName: " + avatarLegacyName
                + "\n\tBirthday: " + avatarBirthday
                + "\n\tPayinfo: " + avatarPayinfo
                + "\n\tOnline status: " + avatarOnlineStatus);
            state default;
        }
     }
     }


     timer()
     timer()
     {
     {
         dump_result_to_local_chat();
         llSay(0, "Sorry, did not get a response for all requested info. Please try again!");
        state default;
     }
     }
}
}
</source>
</source>
= Instructions =
Add the script to an object and start chatting with a friend. See the object remember who chatted last.


= See Also =
= See Also =
Line 210: Line 158:
'''Functions'''
'''Functions'''


[[llDumpList2String]] - insert new lines (or whatever you wish) between strings
[[llRequestAgentData]] - ask to receive information about of an agent, such as birth date
 
[[llRequestAgentData]] - ask to receive an image of an agent, such as a chatter, in pieces


[[llSetText]] - float text over a prim
[[llSetText]] - float text over a prim


{{LSLC|Library}}{{LSLC|Examples}}
{{LSLC|Library}}{{LSLC|Examples}}

Latest revision as of 10:41, 21 January 2016

Introduction

Another avatar or object can ask what your avatar's name is, what your avatar's date-of-birth is, whether payment info is on file for your avatar, etc. The Linden servers will return this information without asking you for permission and without notifying you.

If you can see an avatar's profile, then Profile > 2nd Life will tell you things like Currently Online, Born mm/dd/yyyy, No Payment Info On File. If you can't, then this script can tell you those kinds of things.

Sample Results

---
Avatar info:
    Name: John Doe
    Birthday: 2007-09-23
    Payinfo: Has unused payment info on file.
    Online status: Offline
---

Code

//  Touch prim to get avatar info as shown in the profile
//
//  http://wiki.secondlife.com/wiki/Describe_Chatter

key nameRequestId;
key birthdayRequestId;
key payinfoRequestId;
key onlineStatusRequestId;

string avatarLegacyName;
string avatarBirthday;
string avatarPayinfo;
string avatarOnlineStatus;

integer    gEventsReceived;               // Bit pattern of received dataserver events
integer    gMaskName = 1;
integer    gMaskBirthday = 2;
integer    gMaskPayinfo = 4;
integer    gMaskOnline  = 8;

key        gToucher;

clear_cache()
{
    gEventsReceived = 0;
    avatarLegacyName = "";
    avatarBirthday = "";
    avatarPayinfo = "";
    avatarOnlineStatus = "";
}

default
{
    state_entry()
    {
        llSetTimerEvent(0);
        //  yellow and opaque
        llSetText("<~!~ touch to get avatar info ~!~>", <1, 1, 0>, 1);
    }
    on_rez(integer start_param)
    {
        llResetScript();
    }

    changed(integer change)
    {
        if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
            llResetScript();
    }

    touch_end(integer num_detected)
    {
        gToucher = llDetectedKey(0);
        state working;
    }
}

state working
{
    state_entry()
    {
        llSetText("=== please wait ===", <1, 0, 0>, 1);
        clear_cache();
        nameRequestId = llRequestAgentData(gToucher, DATA_NAME);
        birthdayRequestId = llRequestAgentData(gToucher, DATA_BORN);
        payinfoRequestId = llRequestAgentData(gToucher, DATA_PAYINFO);
        onlineStatusRequestId = llRequestAgentData(gToucher, DATA_ONLINE);
        llSetTimerEvent(10);
    }

    dataserver(key query_id, string data)
    {
        if (query_id == NULL_KEY)
            return;

        if (query_id == nameRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskName;
            avatarLegacyName = data;
        }
        else if (query_id == birthdayRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskBirthday;
            avatarBirthday = data;
        }
        else if (query_id == payinfoRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskPayinfo;
            integer payInfo = (integer)data;
            if (payInfo  & ~(PAYMENT_INFO_ON_FILE | PAYMENT_INFO_USED))
                avatarPayinfo = "- payinfo request failed -";

            else
            {
                integer hasPayinfo = (payInfo & PAYMENT_INFO_ON_FILE);
                integer usedPayinfo = (payInfo & PAYMENT_INFO_USED);
                avatarPayinfo = "Has no payment info on file.";
                if (hasPayinfo)
                {
                    avatarPayinfo = "Has unused payment info on file.";
                    if (usedPayinfo)
                        avatarPayinfo =  "Has used payment info on file.";
                }
            }
        }
        else if (query_id == onlineStatusRequestId)
        {
            gEventsReceived = gEventsReceived | gMaskOnline;
            avatarOnlineStatus = "Offline";
            if ( (integer) data )
                avatarOnlineStatus = "Online";
        }

        if (gEventsReceived == (gMaskName | gMaskBirthday | gMaskPayinfo | gMaskOnline ) )
        {
            llSay(0, "Avatar info:"
                + "\n\tName: " + avatarLegacyName
                + "\n\tBirthday: " + avatarBirthday
                + "\n\tPayinfo: " + avatarPayinfo
                + "\n\tOnline status: " + avatarOnlineStatus);
            state default;
        }
    }

    timer()
    {
        llSay(0, "Sorry, did not get a response for all requested info. Please try again!");
        state default;
    }
}

See Also

Functions

llRequestAgentData - ask to receive information about of an agent, such as birth date

llSetText - float text over a prim