Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I use onChatted to check for multiple messages for the same function?

Asked by
chrono2 189
8 years ago

I'm writing a very rudimentary pseudo-AI script which in essence is used for roleplay purposes only. It's designed to detect a series of sentences and respond accordingly.

Let's say that I want to turn it into Jarvis from Iron Man, and I want it to activate a suit morph or something whenever it detects that I say the words: "Jarvis" and "Suit" in any order or context, or "Jarvis" and "Armour" in any order or context.

How would I code that event?

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

This is a script that looks for keywords in phrases. If your phrase has ALL of the keywords in it,

for exampleJarvis + Armour or even Jarvis + heal,

it will run the function for the corresponding phrases. The functions for each phrase are inside the table phrases

This should be pretty straightforward but pls let me know if you have any questions - my code can be confusing

01match = nil
02 
03phrases = {
04    ["Amour"] = {
05        words = {"Jarvis" , "Armour"},
06        func = function( p ) -- functions go HERE
07            print(p.Name .. " activated armor function")   
08        end
09    },
10    ["Health"] = {
11        words = {"Jarvis","Heal"},
12 
13        func = function( p ) -- functions go HERE
14            print(p.Name .. " activated health function")  
15        end
View all 57 lines...
0
That works perfectly! Exactly what I needed. I can learn a lot from this. chrono2 189 — 8y
Ad

Answer this question