Posted 20 July 2016 - 03:45 PM
I made this in lurcraft for computronics chatbox, it worked. Now after a few months i went to pixel worlds. They didnt have computronics so i used the peripherals++ one which works the exact same. I try it now but when i run it it just stops like after a second. Im confused how its happening. Its setup the exact same way it was like when i first made it. Theres no errors or nothing when i run it, it just runs and stops after like a second.The confusing thing is it shouldnt stop running :/
Code:
Code:
-- \194\167 for section symbol
chatbox = peripheral.wrap("top")
term.redirect(peripheral.wrap("back"))
mon = peripheral.wrap("back")
term.clear()
term.setCursorPos(1,1)
mon.clear()
mon.setCursorPos(1,1)
chatBoxName = "\194\1678\194\167lRockyBot\194\1677\194\167o"
chatBotRaw = "RockyBot"
function shout(msg)
print("[Console] Sent message: \'"..msg.."\'")
chatbox.say(msg)
end
function log(usr,msg)
print("[Console] "..usr.." executed command \'"..msg.."\'")
end
function split(str)
if #str>0 then return str:sub(1,1),split(str:sub(2)) end
end
function mysplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
term.write("--------------- "..chatBotRaw.." --------------------------")
chatbox.setName(chatBoxName)
while true do
event,side,username,message = os.pullEvent( "chat_message" )
commandS={split(message)}
commandP={mysplit(message,"%S+")}
print(t)
print(commandP)
if commandS[1] == "!" then
log(username,message)
if fs.exists("cbScripts\\"..message) then
shell.run("cbScripts\\"..message)
else
chatbox.say("\194\1678@"..username.." Invalid command. Do \'!Help\' to get \194\1678a list of commands")
end
else
print("[Console] Message starts with \'"..commandS[1].."\'. Ignoring...")
end
end