Describe Chatter

From Second Life Wiki
Revision as of 10:43, 1 November 2012 by Kireji Haiku (talk | contribs) (rewrote example script cause it would not give the assume result but fail when the dataserver event is not called)
Jump to navigation Jump to search

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.

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.

Sample Results

---
Avatar info:
    Name: John Doe
    Birthday: 2007-09-23
    Payinfo: Has payment info on file but did not use it.
    Online status: Offline
---

Code

<lsl> // 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;

float timeoutTimeInSeconds; list listOfWhichKeysHaveBeenReceived;

clear_cache() {

   timeoutTimeInSeconds = 10.0;
   nameRequestId = NULL_KEY;
   birthdayRequestId = NULL_KEY;
   payinfoRequestId = NULL_KEY;
   onlineStatusRequestId = NULL_KEY;
   avatarLegacyName = "";
   avatarBirthday = "";
   avatarPayinfo = "";
   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) {

   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)
   {
       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;
       listOfWhichKeysHaveBeenReceived = llListReplaceList(listOfWhichKeysHaveBeenReceived,
                                           [TRUE], 3, 3);
       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)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
           llResetScript();
   }
   touch_start(integer num_detected)
   {
       key touchingAvatarKey = llDetectedKey(0);
       clear_cache();
       initiate_requests_for_avatar_info(touchingAvatarKey);
       llSetTimerEvent(timeoutTimeInSeconds);
   }
   dataserver(key query_id, string data)
   {
       if (query_id == NULL_KEY)
           return;
       process_returned_data(query_id, data);
       if (llListStatistics(LIST_STAT_MEAN, listOfWhichKeysHaveBeenReceived) == 1.0)

// {

           dump_result_to_local_chat();

// }

   }
   timer()
   {
       dump_result_to_local_chat();
   }

} </lsl>

Instructions

Add the script to an object and start chatting with a friend. See the object remember who chatted last.

See Also

Functions

llDumpList2String - insert new lines (or whatever you wish) between strings

llRequestAgentData - ask to receive an image of an agent, such as a chatter, in pieces

llSetText - float text over a prim