MARIA MARTEN'S TALK FILE note: originally, I had implemented this script using if (condition) { thing } else if (condition 2) { thing 2 } else if (condition 3) etc, but an UNDOCUMENTED scripting limitation craps out after 15 or so nested if..the..elses, so, against better judgment, I dumbed the code down to 27 individual IF THEN statements - I hope my students do not see this as I am always on about best-case/worst case optomisation of decsion logic SECONDLIFE: // object listens to any chat on channel // main fxn defined at following URL // http://rpgstats.com/wiki/index.php?title=LlSubStringIndex //variables////////// list keywords = [ "hello", "happened", "scared", "dark", "afternoon", "away", "cursed", "unexplained", "fortune", "sons", "marry", "noise", "investigate", "toolshed", "where", "cellar", "barn", "redbarn", "liaised", "love", "romany", "gypsies", "ignorance", "parents", "situation", "will", "corder", "betrothed" ]; list foundKeywords; //a pocket to hold words string myResponse; //string to hold response(s) integer channel = 2; //set to channel for listening //functions////////// findKeywordInChat (string str)//fxn name says it all { myResponse = "";//clear previous responses foundKeywords = [];// empty pocket for this search // begin looping through list of keywords, // searching chat text for each word from list integer i; for (i = 0; i < llGetListLength(keywords); i++) { string currentKeyword = llList2String(keywords, i); //next fxn returns -1 if no keyword is found integer found = llSubStringIndex(str, currentKeyword); if (found != -1)//if not (no keyword found) then do this { foundKeywords += currentKeyword;// stick word in pocket respond(currentKeyword);//send keyword to response builder } } if (foundKeywords == []) { // say something if the keyword is not found myResponse += "I am sorry, I do not know anything about that."; } llWhisper(0,myResponse);//report back to anyone within 10 meters // change "Whisper" to "Say" to speak to anyone withing 20 meters } respond (string word)//builds response text { if (word == "hello") myResponse += "What happened? Where am i? Is that you Will? - talk to me by starting your chat with /"+ (string)channel; if (word == "happened") myResponse += "It is dark, I am scared, there was a noise and then nothing. "; if (word == "scared") myResponse += "I do not understand what has happened to me. "; if (word == "dark") myResponse += "I was to meet Will here in the afternoon. "; if (word == "afternoon") myResponse += "Will had promised to take me away and marry me. "; if (word == "away") myResponse += "Anywhere but this farm - cursed it is. "; if (word == "cursed") myResponse += "So much unexplained death = the brothers Corder and my dearest sons. "; if (word == "unexplained") myResponse += "Well, unexpected and close together, such bad fortune. "; if (word == "fortune") myResponse += "Reba fortold much sorrow and hardship for this family. "; if (word == "sons") myResponse += "I have had three beautiful sons, now only one remains. "; if (word == "marry") myResponse += "A wife for the third time I am to be - much married am I. "; if (word == "noise") myResponse += "Someone knocked something over in the toolshed, I went to investigate. "; if (word == "investigate") myResponse += "I thought it might have been Will. I know my way around. "; if (word == "toolshed") myResponse += "Will keeps his workshop tools and farm equipment there. "; if (word == "where") myResponse += "This looks like the cellar. How did I get here? "; if (word == "cellar") myResponse += "I was upstairs in the barn, waiting like I was told. "; if (word == "barn") myResponse += "the Redbarn is where Will and I often liaised. "; if (word == "redbarn") myResponse += "Well, it is just normal thatch, but has bits of red roof. "; if (word == "liaised") myResponse += "Well, we were in love, at least that is what he said. "; if (word == "love") myResponse += "My true love is Romany, but my parents would never approve. "; if (word == "romany") myResponse += "Gypsies the locals call them. Ignorance is a poweful force. "; if (word == "gypsies") myResponse += "Free spirits - I wish I was with Andree now, but alas his betrothed would not be impressed. "; if (word == "ignorance") myResponse += "Will and his father always said an education was wasted on a woman. "; if (word == "parents") myResponse += "Mother and Father are very strict and did not understand my situation. "; if (word == "situation") myResponse += "It is impossible in such a backward place for a woman of letters. "; if (word == "will") myResponse += "William Corder - my betrothed, do you know him? "; if (word == "corder") myResponse += "This barn is rented by his family. Mrs Cook the nosy neighbor charges too much for this dump. "; if (word == "betrothed") myResponse += "William agreed to make an honest woman of me, when he found out I was with child. "; } //states//////////// default { state_entry() { //next line converts list to string string allKeywords = llDumpList2String(keywords,", "); llSay(0, "Good day, you can talk to me on channel " + (string)channel); llListen( channel, "", NULL_KEY, "" ); } listen(integer channel, string name, key id, string message) { findKeywordInChat(message); } touch_start(integer total_number) { llSay(0, "What happened? Where am i? Is that you Will? - talk to me by starting your chat with /"+ (string)channel); } }