// NagBot // For when you know you really should be doing something else, but you // just couldn't help but log on, just for five minutes, honest. // Ordinal Malaprop // 2006-09-28 //-------------------------------------------------------------------- // Variables // Customise these as desired... list NAG_TOPICS = [ "clean the kitchen", "do the laundry", "finish that project", "wash your poseballs", "brush the hedgehog" ]; // % is replaced by the nag topic in these list NAG_PHRASES = [ "Did you %?", "When are you going to %?", "Do I have to tell you again to %?", "I hope you're going to %.", "Can't you get your act together and %?", "You're not doing anything important right now - go and % instead.", "Stop wasting time and %!", "Have you forgotten to %?", "For once in your life, be useful and %." ]; // Length of time between nags initially - halves after each one float START_NAG = 300.0; // Minimum time between nags float MIN_NAG = 10.0; // Misc global variables, leave them alone float gInterval = 0.0; key gQuery = NULL_KEY; //-------------------------------------------------------------------- // Function to pick a random item from a list of strings string random(list strings) { return llList2String(strings, llFloor(llFrand((float)llGetListLength(strings)))); } //-------------------------------------------------------------------- // The central nagging function nag() { list nag1 = llParseString2List(random(NAG_PHRASES), ["%"], []); string nag2 = llList2String(nag1, 0) + random(NAG_TOPICS) + llList2String(nag1, 1); llInstantMessage(llGetOwner(), nag2); } //-------------------------------------------------------------------- // Initial non-nagging state default { state_entry() { // Initially check to see if the owner is online gQuery = llRequestAgentData(llGetOwner(), DATA_ONLINE); // and check every now and then afterwards llSetTimerEvent(START_NAG); } timer() { gQuery = llRequestAgentData(llGetOwner(), DATA_ONLINE); } dataserver(key queryid, string data) { if (queryid != gQuery) return; if ((integer)data) { // Owner is online! Nag them! state nagging; } } } //-------------------------------------------------------------------- // Nag state state nagging { state_entry() { nag(); gInterval = START_NAG; llSetTimerEvent(gInterval); llListen(0, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { // It doesn't really listen; whatever you say it will keep nagging nag(); llSetTimerEvent(gInterval); } timer() { // Before nagging, check that owner is actually online gQuery = llRequestAgentData(llGetOwner(), DATA_ONLINE); } dataserver(key queryid, string data) { if (queryid != gQuery) return; if ((integer)data) { // They're still online - keep nagging! nag(); if (gInterval > MIN_NAG) { gInterval = gInterval / 2; if (gInterval < MIN_NAG) gInterval = MIN_NAG; llSetTimerEvent(gInterval); } } else { // Owner has logged off - stop nagging them state default; } } state_exit() { llListenRemove(0); } }