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 = {}
|
local modem = {}
|
||||||
|
|
||||||
modem = {}
|
|
||||||
|
|
||||||
function modem.open(port)
|
function modem.open(port)
|
||||||
-- Nothing
|
-- Nothing
|
||||||
|
|
@ -16,6 +14,6 @@ function modem.broadcast(port, msg)
|
||||||
network.broadcast(port, msg)
|
network.broadcast(port, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
component.modem = modem
|
return {
|
||||||
|
modem = modem,
|
||||||
return component
|
}
|
||||||
|
|
|
||||||
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
|
local addr_num = 0
|
||||||
last_msg = nil
|
local last_msg = nil
|
||||||
|
|
||||||
function event.listen(event, callback)
|
function event.listen(event, callback)
|
||||||
if event ~= "modem_message" then
|
if event ~= "modem_message" then
|
||||||
|
|
@ -20,6 +21,8 @@ function event.listen(event, callback)
|
||||||
dist=dist,
|
dist=dist,
|
||||||
msg=msg,
|
msg=msg,
|
||||||
}
|
}
|
||||||
|
-- Inject local address so the check passes
|
||||||
|
component.modem.address = addr1
|
||||||
callback(ev, addr1, addr2, port, dist, msg)
|
callback(ev, addr1, addr2, port, dist, msg)
|
||||||
end
|
end
|
||||||
network.register(addr, ev_callback)
|
network.register(addr, ev_callback)
|
||||||
|
|
|
||||||
10
network.lua
10
network.lua
|
|
@ -1,9 +1,9 @@
|
||||||
network = {}
|
local network = {
|
||||||
network.allow_blackhole = false
|
allow_blackhole = false,
|
||||||
|
}
|
||||||
|
|
||||||
nodes = {}
|
local nodes = {}
|
||||||
|
local active_node = {}
|
||||||
active_node = {}
|
|
||||||
|
|
||||||
function network.register(addr, callback)
|
function network.register(addr, callback)
|
||||||
if nodes[addr] ~= nil then
|
if nodes[addr] ~= nil then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue