Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local m = component.proxy(component.list("modem")())
- m.setStrength(100)
- m.open(100)
- m.broadcast(100, "hello")
- local event, listeners, timers = {}, {}, {}
- local lastInterrupt = -math.huge
- function event.listen(name, callback)
- checkArg(1, name, "string")
- checkArg(2, callback, "function")
- if listeners[name] then
- for i = 1, #listeners[name] do
- if listeners[name][i] == callback then
- return false
- end
- end
- else
- listeners[name] = {}
- end
- table.insert(listeners[name], callback)
- return true
- end
- event.listen("modem_message", function(_,_,from,port,_,message)
- print(tostring(message))
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement