Posted 01 July 2014 - 05:16 AM
I am trying to have the computer read from chat, replace all '@' with '.' (because I can't type . in chat), then execute the command. When I tell it a command it throws the error:
Please help! Thanks!
string:1:attempt to index ? (a nil value)
Here is the code:
chat = peripheral.wrap("left")
local cmd = nil
while true do
event, side, player, mes = os.pullEvent("chat_message")
print(player.." said: "..mes)
if mes:sub(0,9) == "Chatbox, " then
cmd = mes:sub(10,-1)
cmd = string.gsub(cmd,"[@]",".")
local command = loadstring(cmd)()
end
end
Please help! Thanks!