Compare commits

...

26 Commits

Author SHA1 Message Date
464b692f69 Update entrypointclient.lua 2025-12-24 21:48:18 +00:00
8d0bcf6599 i tried 2025-12-24 21:42:06 +00:00
f330830e6c made it safer 2025-12-24 21:23:21 +00:00
34d9397ab4 made the network safer 2025-12-24 21:22:30 +00:00
533b8f126d Update lua-minify.lua 2025-12-24 05:18:14 +00:00
5ad67d6f3a Update lua-minify.lua 2025-12-24 05:16:44 +00:00
358c7aeb54 Add lua-minify.lua 2025-12-24 05:12:02 +00:00
21573b57b4 Update containers_minified.lua 2025-11-20 08:20:20 +00:00
27ded0f69a Update containers.lua 2025-11-20 08:18:09 +00:00
5ef412e9f3 Update conatiners_minified.lua 2025-11-20 05:55:54 +00:00
c25899c22b Update conatiners_minified.lua 2025-11-20 05:27:35 +00:00
6f24903281 Update conatiners.lua 2025-11-20 05:26:25 +00:00
e8f6ee2a50 Add conatiners_minified.lua 2025-11-20 00:55:22 +00:00
53bfcd57fb Add conatiners.lua 2025-11-20 00:54:22 +00:00
f408acc81e Update minified_disklock.lua 2025-11-19 04:13:31 +00:00
1814070fb6 Update disklock.lua 2025-11-19 04:12:04 +00:00
CadenCoaster
6ec10e2edf Replace fixed distance with max_distance variable 2025-10-21 09:20:53 -07:00
CadenCoaster
5f09b5b81d Update print statement from 'Hello' to 'Goodbye' 2025-10-20 15:12:11 -07:00
CadenCoaster
c318867d6d Create disklock.lua 2025-10-20 15:11:31 -07:00
CadenCoaster
8c41220f9a libDeflate.lua 2025-10-19 19:12:05 -07:00
CadenCoaster
374d239407 Update meshrouter.lua 2025-10-19 13:51:56 -07:00
CadenCoaster
b1c4a68490 Update modem initialization to check for wireless 2025-10-19 13:51:27 -07:00
CadenCoaster
9cd255c938 Update modem initialization to check for wireless 2025-10-19 13:51:14 -07:00
CadenCoaster
feb764c379 Ensure os.shutdown() is called with a newline 2025-10-19 13:44:50 -07:00
CadenCoaster
fe7accadb7 Update meshrouter.lua 2025-10-19 13:44:17 -07:00
CadenCoaster
82615a9d82 Implement default route generation in mesh router
Added a function to generate default routes for clients in the distance map.
2025-10-19 13:42:46 -07:00
9 changed files with 3861 additions and 13 deletions

1061
containers.lua Normal file

File diff suppressed because one or more lines are too long

1
containers_minified.lua Normal file

File diff suppressed because one or more lines are too long

680
disklock.lua Normal file

File diff suppressed because one or more lines are too long

View File

@@ -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

File diff suppressed because one or more lines are too long

2094
lua-minify.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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)

View File

@@ -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

File diff suppressed because one or more lines are too long