Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local CB
- function splitString(str)
- local fields = {}
- str:gsub("([^ ]+)", function(c) table.insert(fields, c) end)
- return fields
- end
- function init()
- CB = peripheral.find("chatBox")
- if CB == nil then error("chatBox not found") end
- end
- function mainLoop()
- while true do
- event, username, message = os.pullEvent("chat")
- if username == "_LK005_" then
- splitMessage = splitString(message)
- local identifier = splitMessage[1]
- local command = splitMessage[2]
- local switchName = splitMessage[3]
- local state = splitMessage[4]
- if identifier == "-" then
- if switchName == tArgs[1] then
- print("Command: "..command)
- if command == "switch" then
- print("Setting "..switchName.." to "..state)
- if state == "on" then
- redstone.setOutput(tArgs[2], true)
- elseif state == "off" then
- redstone.setOutput(tArgs[2], false)
- end
- end
- end
- end
- end
- end
- end
- init()
- mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement