Ok, this is supposed to record what is in chat to a client side file, then when i say a sentence with "ai" in it, it will take three random words from the sentence, search for them in the file, and print the line they're found in to chat... Why isn't it working???
Code:
@name AI - Newest
@outputs [Chat2 DumpPile Data]:array
@outputs [Word1 Word2 Word3 AI]:string
@outputs Temp1
runOnChat(1)
fileLoad("data.txt")
Data = (lastSaid():explode("."))
fileAppend("data.txt",glonEncode(Data))
Chat = lastSaid():lower()
Chat2 = Chat:explode(" ")
DataBank = glonDecode(fileRead("data.txt"))
AI = "AI"
if (Chat:find(AI:lower()) | Chat2:count() >=4) {
Word1 = Chat2:string(randint(1,Chat2:count()))
Word2 = Chat2:string(randint(1,Chat2:count()))
Word3 = Chat2:string(randint(1,Chat2:count()))
for(Temp1 = Temp1, Temp1+1) {
if (ops() > 4000) {break}
Line = DataBank:string(Temp1)
if (Line:find(Word1) | Line:find(Word2) & Line:find(Word3)) {
DumpPile:pushString(DataBank:string(Temp1))
}
}
if (Temp1 > DataBank:count()) {
if (DumpPile:count() >= 1) {
hint(DumpPile:string(randint(1,DumpPile:count())),3)
}
}
}
Bookmarks