+ Reply to Thread
Results 1 to 4 of 4

Thread: AI - File search and string retrieval help...

  1. #1
    Wire Noob livestrong2431's Avatar
    Join Date
    Oct 2009
    Posts
    12

    Question Loops help etc.

    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)
                }
            }
    }
    Last edited by livestrong2431; 03-05-2010 at 06:14 PM.

  2. #2
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: AI - File search and string retrieval help... (Edited to make sense =O)

    You are trying to use the file before the 10 second delay between asking to load it and E2 letting you read from it. You also do not use the contents of data.txt in any way.

    For searching, use a loop.

  3. #3
    Wire Noob livestrong2431's Avatar
    Join Date
    Oct 2009
    Posts
    12

    Default Re: AI - File search and string retrieval help... (Edited to make sense =O)

    -------------------------------
    Last edited by livestrong2431; 03-05-2010 at 06:12 PM.

  4. #4
    Wire Noob livestrong2431's Avatar
    Join Date
    Oct 2009
    Posts
    12

    Question For loops file searching

    -----------------------
    Last edited by livestrong2431; 03-05-2010 at 06:12 PM.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots