Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modules = peripheral.wrap("back")
- modules.capture("^!")
- rednet.open("right")
- targets = {}
- id = 0
- function addTargets(msg)
- local point = string.find(msg, ",")
- if point and point > 2 then
- table.insert(targets, #targets + 1, string.sub(msg,1, point-1))
- print(string.sub(msg,1, point-1))
- addTargets(string.sub(msg, point + 1))
- else
- table.insert(targets, #targets + 1, msg)
- print(msg)
- end
- end
- function chat()
- while true do
- local _, message, pattern = os.pullEvent("chat_capture")
- if string.sub(message, 1,8) == "!onsight" then
- if string.sub(message,10) == "default" then
- rednet.send(id, {"Skeleton","Creeper","Zombie","Spider","Witch"})
- rednet.send(id, 0.5)
- elseif string.len(string.sub(message,10)) > 0 then
- for i = 1, #targets do
- targets[i] = nil
- end
- addTargets(string.sub(message,10))
- rednet.send(id, targets)
- end
- elseif string.sub(message, 1,6) == "!power" then
- rednet.send(id, tonumber(string.sub(message, 8)))
- elseif string.sub(message, 1,3) == "!id" then
- id = tonumber(string.sub(message,4))
- elseif string.sub(message, 1,9) == "!offsight" then
- rednet.send(id, {})
- end
- end
- end
- chat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement