Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require('event')
- local fs = require('filesystem')
- local component = require('component')
- local net = component.modem
- local rs = component.redstone
- local running = true
- -- Callbacks
- local function networkCallback(type, myaddr, senderaddress, port, distance, message)
- -- print(myaddr .. " " .. senderaddress .. " " .. port .. " " .. distance .. " " .. message)
- if port == 123 then
- if message == "on" then
- for k,v in component.list() do
- if v == "colorful_lamp" then
- component.proxy(k).setLampColor(31744)
- end
- end
- elseif message == "off" then
- for k,v in component.list() do
- if v == "colorful_lamp" then
- component.proxy(k).setLampColor(0)
- end
- end
- end
- end
- end
- -- Main Code
- net.open(123)
- event.listen("modem_message", networkCallback)
- while running do
- os.sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement