Describe Chatter
Revision as of 20:03, 28 October 2007 by Ppaatt Lynagh (talk | contribs) (→Code: link back with this page)
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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 legal name is, what your avatar's date-of-birth is, whether real 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.
Sample Results
--- J Doe Born 2007-09-01 Has no money Online ---
Code
// Chat to see yourself as others do // http://wiki.secondlife.com/wiki/Describe_Chatter key theDataNameKey; key theDataBornKey; key theDataPayInfoKey; key theDataOnlineKey; integer sendableKeyings = 4; integer receivedKeyings; string theDataNameString; string theDataBornString; string theDataPayInfoString; string theDataOnlineString; // Say why chat with this script startup() { scrubKeys(); llOwnerSay("You chat at the mirror, mirror, on the wall ..."); list lines = [llGetObjectName(), llGetObjectDesc()]; string label = llDumpList2String(lines, "\n---\n"); llSetText(label, <1.0, 1.0, 1.0>, 1.0); } // Forget old chat scrubKeys() { llSetText("", <0.0, 0.0, 0.0>, 1.0); theDataNameKey = NULL_KEY; theDataBornKey = NULL_KEY; theDataPayInfoKey = NULL_KEY; theDataOnlineKey = NULL_KEY; receivedKeyings = 0; } // Float an image of the chatter above the object receiveKeys() { string text = "" + "---\n" + " \n" + theDataNameString + "\n" + " \n" + "Born " + theDataBornString + "\n" + " \n" + toPayInfoEcho(theDataPayInfoString) + "\n" + " \n" + toOnlineEcho(theDataOnlineString) + "\n" + " \n" + "---\n" + " \n" ; vector color = <0.0, 1.0, 1.0>; float opacity = 1.0; llSetText(text, color, opacity); } // Convert to string from PAYMENT_INFO string toPayInfoEcho(string data) { integer payInfo = (integer) data; if (payInfo == 0) { return "Has no money"; } else if (payInfo & PAYMENT_INFO_USED) { return "Has spent money"; } else if (payInfo & PAYMENT_INFO_ON_FILE) { return "Has money"; } else { return data; } } // Convert to string from DATA_ONLINE string toOnlineEcho(string data) { integer online = (integer) data; if (!online) { return "Not online"; } return "Online"; } // Receive an image of the chatter catchKey(key queryid, string data) { if (queryid == theDataNameKey) { theDataNameString = data; } else if (queryid == theDataBornKey) { theDataBornString = data; } else if (queryid == theDataPayInfoKey) { theDataPayInfoString = data; } else if (queryid == theDataOnlineKey) { theDataOnlineString = data; } } // Ask to receive an image of the chatter in pieces sendKeys(key who) { theDataNameKey = llRequestAgentData(who, DATA_NAME); theDataBornKey = llRequestAgentData(who, DATA_BORN); theDataPayInfoKey = llRequestAgentData(who, DATA_PAYINFO); theDataOnlineKey = llRequestAgentData(who, DATA_ONLINE); } // For each reset ... default { // Listen to all ordinary chat state_entry() { startup(); llListen(0, "", NULL_KEY, ""); } // Ask to receive an image of the chatter in pieces listen(integer channel, string name, key id, string message) { if (llGetAgentSize(id) != ZERO_VECTOR) { scrubKeys(); sendKeys(id); } } // Receive every piece of an image of the chatter dataserver(key queryid, string data) { catchKey(queryid, data); receivedKeyings += 1; if (receivedKeyings == sendableKeyings) { receiveKeys(); } } }
Instructions
Add the script to an object and start chatting with a friend. See the object remember who chatted last.
See Also
Functions
llRequestAgentData - ask to receive an image of an agent, such as a chatter, in pieces