Compare commits
26 Commits
5924cba842
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 464b692f69 | |||
| 8d0bcf6599 | |||
| f330830e6c | |||
| 34d9397ab4 | |||
| 533b8f126d | |||
| 5ad67d6f3a | |||
| 358c7aeb54 | |||
| 21573b57b4 | |||
| 27ded0f69a | |||
| 5ef412e9f3 | |||
| c25899c22b | |||
| 6f24903281 | |||
| e8f6ee2a50 | |||
| 53bfcd57fb | |||
| f408acc81e | |||
| 1814070fb6 | |||
|
|
6ec10e2edf | ||
|
|
5f09b5b81d | ||
|
|
c318867d6d | ||
|
|
8c41220f9a | ||
|
|
374d239407 | ||
|
|
b1c4a68490 | ||
|
|
9cd255c938 | ||
|
|
feb764c379 | ||
|
|
fe7accadb7 | ||
|
|
82615a9d82 |
1061
containers.lua
Normal file
1061
containers.lua
Normal file
File diff suppressed because one or more lines are too long
1
containers_minified.lua
Normal file
1
containers_minified.lua
Normal file
File diff suppressed because one or more lines are too long
680
disklock.lua
Normal file
680
disklock.lua
Normal file
File diff suppressed because one or more lines are too long
@@ -1,5 +1,7 @@
|
||||
llocal max_distance = {}
|
||||
|
||||
local pullEvent = os.pullEventRaw
|
||||
local modem = peripheral.find("modem")
|
||||
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
|
||||
term.clear()
|
||||
term.setCursorPos(1,1)
|
||||
_G.network = {}
|
||||
@@ -9,11 +11,12 @@ if not modem then
|
||||
end
|
||||
local message_queue = {}
|
||||
modem.open(15125)
|
||||
local canidate = {id = -1, distance = 170}
|
||||
local canidate = {id = -1, distance = 764}
|
||||
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
||||
function ()
|
||||
while true do
|
||||
local _, _, channel, _, msg, distance = pullEvent("modem_message")
|
||||
max_distance[msg.sender] = math.max(distance,max_distance[msg.sender] or 0)
|
||||
if channel == 15125 then
|
||||
if msg.protocol == "entrypoint_advertise" then
|
||||
if distance < canidate.distance then
|
||||
@@ -34,9 +37,9 @@ local function receive()
|
||||
if msg.protocol == "heartbeat" and msg.target == os.getComputerID() and msg.sender == canidate.id then
|
||||
last_heartbeat = os.epoch("utc")
|
||||
modem.transmit(15125,15125,{protocol="heartbeat_response",sender=os.getComputerID(),target=canidate.id})
|
||||
if distance > 170 then
|
||||
if distance > (max_distance[msg.sender]or 764) then
|
||||
modem.transmit(15125,15125,{protocol="entrypoint_disconnect",sender=os.getComputerID(),target=canidate.id})
|
||||
canidate = {id = -1, distance = 170}
|
||||
canidate = {id = -1, distance = (max_distance[msg.sender]or 764)}
|
||||
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
||||
function ()
|
||||
while true do
|
||||
@@ -76,7 +79,7 @@ end
|
||||
local function connect()
|
||||
while true do
|
||||
if os.epoch("utc") - last_heartbeat > 200 then
|
||||
canidate = {id = -1, distance = 170}
|
||||
canidate = {id = -1, distance = 764}
|
||||
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
||||
function ()
|
||||
while true do
|
||||
|
||||
1
libDeflate.lua
Normal file
1
libDeflate.lua
Normal file
File diff suppressed because one or more lines are too long
2094
lua-minify.lua
Normal file
2094
lua-minify.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
local interactions = {}
|
||||
local radio = peripheral.find("radio_tower")
|
||||
local modem = peripheral.find("modem")
|
||||
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
|
||||
local distancemap = {}
|
||||
local message_queue = {}
|
||||
|
||||
@@ -41,7 +41,7 @@ if radio and modem then
|
||||
local data = {os.pullEvent()}
|
||||
if data[1] == "radio_message" then
|
||||
data[3] = textutils.unserialise(data[3])
|
||||
if data[3]._target == os.getComputerID() or data[3]._target == nil then return data[2], data[3], data[4] end
|
||||
if data[3]._target == os.getComputerID() or data[3]._target == nil and data[4] < 2611 then return data[2], data[3], data[4] end
|
||||
elseif data[1] == "modem_message" then
|
||||
if data[5]._target == os.getComputerID() or data[5]._target == nil then return data[2], data[5], data[6] end
|
||||
end
|
||||
@@ -61,7 +61,7 @@ elseif radio then
|
||||
while true do
|
||||
local data = {os.pullEvent("radio_message")}
|
||||
data[3] = textutils.unserialise(data[3])
|
||||
if data[3]._target == os.getComputerID() or data[3]._target == nil then return data[2], data[3], data[4] end
|
||||
if data[3]._target == os.getComputerID() or data[3]._target == nil and data[4] < 2611 then return data[2], data[3], data[4] end
|
||||
end
|
||||
end
|
||||
function interactions.send(message,target)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local interactions = {}
|
||||
local radio = peripheral.find("radio_tower")
|
||||
local modem = peripheral.find("modem")
|
||||
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
|
||||
local distancemap = {}
|
||||
local clients = {}
|
||||
local message_queue = {}
|
||||
@@ -82,7 +82,7 @@ if radio and modem then
|
||||
local data = {os.pullEvent()}
|
||||
if data[1] == "radio_message" then
|
||||
data[3] = textutils.unserialise(data[3])
|
||||
if data[3]._target == os.getComputerID() or data[3]._target == nil then return data[2], data[3], data[4] end
|
||||
if data[3]._target == os.getComputerID() or data[3]._target == nil and data[4] < 2611 then return data[2], data[3], data[4] end
|
||||
elseif data[1] == "modem_message" then
|
||||
if data[5]._target == os.getComputerID() or data[5]._target == nil and data[3] == 15124 then return data[2], data[5], data[6] end
|
||||
if data[3] == 15125 then
|
||||
@@ -126,7 +126,14 @@ queue_message({protocol="getroutes"})
|
||||
interactions.send({protocol="route_erase",destination=os.getComputerID()})
|
||||
queue_message({protocol="route",destination=os.getComputerID(),distance=0})
|
||||
local heartbeat = false
|
||||
|
||||
local function generate_default_routes()
|
||||
local map = {}
|
||||
map[os.computerID()] = {dist = 0, sender = os.computerID()}
|
||||
for client,_ in pairs(clients) do
|
||||
map[client] = {dist = 1, sender = client}
|
||||
end
|
||||
return map
|
||||
end
|
||||
local function recieve()
|
||||
while true do
|
||||
local _, msg = interactions.receive()
|
||||
@@ -188,8 +195,7 @@ while true do
|
||||
if (not msg.visited) then msg.visited = {} end
|
||||
msg.visited[#msg.visited+1] = os.getComputerID()
|
||||
print("rerouting")
|
||||
distancemap = {}
|
||||
distancemap[os.computerID()] = {dist = 0, sender = os.computerID()}
|
||||
distancemap = generate_default_routes()
|
||||
queue_message({protocol="getroutes"})
|
||||
queue_message(msg)
|
||||
end
|
||||
@@ -219,6 +225,7 @@ local function heartbeat_f()
|
||||
end
|
||||
end)
|
||||
if not heartbeat then
|
||||
print(k, "timed out")
|
||||
distancemap[k] = nil
|
||||
queue_message({protocol="reroute"})
|
||||
end
|
||||
|
||||
1
minified_disklock.lua
Normal file
1
minified_disklock.lua
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user