Posted 30 August 2013 - 10:56 PM
I am currently using the Miscperipherals chat box that they added in. I'm trying to get it where you can ask the turtle a question such as "turtle: speak" or "turtle: i would like for you to speak" or "turtle: for the last time will you speak to me". I want it so that it detects the keywords such as "turtle:" as a make shift "/" for commands and then "speak" which is an example of one of the commands that can be called. I want it so that you don't have to say it in any order but instead have the turtle look for the keywords. As far as ive gotten with previous help is this.
it will work if you do "turtle:speak" or "turtle: speak" but if you try to put anything else in it "turtle: will you speak" it wont run.
m = peripheral.wrap("left")
while true do
event, player, message = os.pullEvent("chat")
local target, command = string.match(message, "^%s*(.+)%s*:%s*(.+)%s*$")
print(target, command) -- debug code
if target == "turtle" and command == "speak" then
m.say("HI")
end
end
it will work if you do "turtle:speak" or "turtle: speak" but if you try to put anything else in it "turtle: will you speak" it wont run.