string owner; //Nearby people list nearby = [""]; //People that are "listening", or that have talked to the AI (or that the AI has talked to) recently. Talking to the AI will be defined as responding in a useable way to its last statement or question, or callling its name. Listeners will be removed after a while of no interaction with the AI. list listeners = ["Vance Sodwind"]; //Nicknames for the object that people might say list nicknames = ["ai test","ai","tester"]; //Things to halt responding for if they're next to a detected word list deny = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]; //List of words or phrases that could be thought of as a "no" type response list no = ["no","nope","negative","nay","nadda","never","not","negative","refuse","can't","cant"]; integer time = 0; string mstr = ""; integer msav; integer denied(string src, string target, integer index) { if(index == -1) { return(1); } else if(mstr == "") { mstr = target; msav = index; } string checkb = ""; string checka = ""; //Character before string if(index != 0) { checkb = llGetSubString(src,index-1,index-1); } //Character after string if(index+llStringLength(target) != llStringLength(src)) { checka = llGetSubString(src,index+llStringLength(target),index+llStringLength(target)); } if(llListFindList(deny,[checkb]) != -1 || llListFindList(deny,[checka]) != -1) { return(1); } else { return(0); } } default { state_entry() { owner = llKey2Name(llGetOwner()); llListen(0,"",NULL_KEY,""); llSetTimerEvent(1); } listen(integer channel, string name, key id, string msg) { //If talker is a listener. if(llListFindList(listeners,[name]) != -1) { //Start "no" check msg = llToLower(msg); string nmsg = msg; integer foundmatch = 0; integer checklength = llGetListLength(no); integer check = 0; //If anything in their statement matches a kind of no. mstr = ""; msav = 0; while(check < checklength && !foundmatch) { string lstring = llList2String(no,check); integer sav = llSubStringIndex(nmsg,lstring); if(!denied(nmsg,lstring,sav)) { foundmatch = 1; } check += 1; //If all comparisons fail and a partial match was made in the last comparisons if(check == checklength && mstr != "") { nmsg = llGetSubString(nmsg,msav+llStringLength(mstr),llStringLength(nmsg)-1); //If there is more after the first detected string, set it up to compare with that more if(llStringLength(nmsg) > 1) { check = 0; } } } if(foundmatch) { llSay(0,"Why not, "+name+"?"); } //End "no" check } } timer() { time += 1; } }