Refactor dummies
Signed-off-by: Rahix <rahix@rahix.de>
This commit is contained in:
parent
6c51c4cb4e
commit
b2a12cc2dc
3 changed files with 17 additions and 16 deletions
|
|
@ -1,8 +1,6 @@
|
|||
network = require("network")
|
||||
local network = require("network")
|
||||
|
||||
component = {}
|
||||
|
||||
modem = {}
|
||||
local modem = {}
|
||||
|
||||
function modem.open(port)
|
||||
-- Nothing
|
||||
|
|
@ -16,6 +14,6 @@ function modem.broadcast(port, msg)
|
|||
network.broadcast(port, msg)
|
||||
end
|
||||
|
||||
component.modem = modem
|
||||
|
||||
return component
|
||||
return {
|
||||
modem = modem,
|
||||
}
|
||||
|
|
|
|||
11
event.lua
11
event.lua
|
|
@ -1,9 +1,10 @@
|
|||
network = require("network")
|
||||
local network = require("network")
|
||||
local component = require("component")
|
||||
|
||||
event = {}
|
||||
local event = {}
|
||||
|
||||
addr_num = 0
|
||||
last_msg = nil
|
||||
local addr_num = 0
|
||||
local last_msg = nil
|
||||
|
||||
function event.listen(event, callback)
|
||||
if event ~= "modem_message" then
|
||||
|
|
@ -20,6 +21,8 @@ function event.listen(event, callback)
|
|||
dist=dist,
|
||||
msg=msg,
|
||||
}
|
||||
-- Inject local address so the check passes
|
||||
component.modem.address = addr1
|
||||
callback(ev, addr1, addr2, port, dist, msg)
|
||||
end
|
||||
network.register(addr, ev_callback)
|
||||
|
|
|
|||
10
network.lua
10
network.lua
|
|
@ -1,9 +1,9 @@
|
|||
network = {}
|
||||
network.allow_blackhole = false
|
||||
local network = {
|
||||
allow_blackhole = false,
|
||||
}
|
||||
|
||||
nodes = {}
|
||||
|
||||
active_node = {}
|
||||
local nodes = {}
|
||||
local active_node = {}
|
||||
|
||||
function network.register(addr, callback)
|
||||
if nodes[addr] ~= nil then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue