local network = require("network") local component = require("component") local event = {} local addr_num = 0 function event.listen(event, callback) if event ~= "modem_message" then error("Event '"..event"' is not supported!") end addr = "A"..addr_num addr_num = addr_num + 1 function ev_callback(ev, local_addr, ...) -- Inject local address so the check passes component.modem.address = local_addr callback(ev, local_addr, ...) end network.register(addr, ev_callback) end function event.ignore(event, callback) if event ~= "modem_message" then error("Event '"..event"' is not supported!") end network.deregister(network.get_scene()) end function event.pullFiltered(timeout, filter) while true do local msg = table.pack(network.pull()) if msg == nil then return nil elseif filter(table.unpack(msg)) then return table.unpack(msg) end end end return event