Compare commits

...

21 Commits

Author SHA1 Message Date
beafcfd29f Update lua-minify.lua 2025-12-24 23:19:38 +00:00
5f64113546 Update lua-minify.lua 2025-12-24 23:18:32 +00:00
52afc41061 Update meshrouterentrypoint.lua 2025-12-24 23:16:15 +00:00
8eb9766874 Update entrypointclient.lua 2025-12-24 23:15:48 +00:00
9820bd4fa0 Update meshrouterentrypoint.lua 2025-12-24 22:29:55 +00:00
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
8 changed files with 3155 additions and 21 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

View File

@@ -28,13 +28,14 @@ local function deepcopy(o, seen)
end
local realfs = deepcopy(fs)
local function getRom(path)
if not path then path = "/rom" end
local rom_cache = nil
local function buildRom(path)
local out = {}
for _,file in ipairs(realfs.list(path)) do
local fullPath = realfs.combine(path, file) -- use realfs here to avoid recursing into _G.fs
for _, file in ipairs(realfs.list(path)) do
local fullPath = realfs.combine(path, file)
if realfs.isDir(fullPath) then
out[file] = getRom(fullPath)
out[file] = buildRom(fullPath)
else
local handle = realfs.open(fullPath, "r")
out[file] = handle.readAll()
@@ -44,6 +45,13 @@ local function getRom(path)
return out
end
local function getRom()
if not rom_cache then
rom_cache = buildRom("/rom")
end
return rom_cache
end
local function getFileSystem()
if filesystem then filesystem.rom = getRom() return filesystem end
if not realfs.exists("fs") then

View File

@@ -1,5 +1,3 @@
local max_distance = 220
local pullEvent = os.pullEventRaw
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
term.clear()
@@ -11,14 +9,15 @@ if not modem then
end
local message_queue = {}
modem.open(15125)
local canidate = {id = -1, distance = max_distance}
local canidate = {id = -1, distance = 764, max_distance=0}
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
function ()
while true do
local _, _, channel, _, msg, distance = pullEvent("modem_message")
if channel == 15125 then
if msg.protocol == "entrypoint_advertise" then
if distance < canidate.distance then
if distance < canidate.distance and distance < (msg.max_distance or 128) then
canidate.max_distance = (msg.max_distance or 128)
canidate.id = msg.sender
canidate.distance = distance
end
@@ -36,9 +35,11 @@ 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 > max_distance then
canidate.distance = distance
canidate.max_distance = msg.max_distance
if distance > (msg.max_distance or 764) then
modem.transmit(15125,15125,{protocol="entrypoint_disconnect",sender=os.getComputerID(),target=canidate.id})
canidate = {id = -1, distance = max_distance}
canidate = {id = -1, distance = 764, max_distance=0}
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
function ()
while true do
@@ -46,6 +47,7 @@ local function receive()
if channel == 15125 then
if msg.protocol == "entrypoint_advertise" then
if distance < canidate.distance then
canidate.max_distance = msg.max_distance
canidate.id = msg.sender
canidate.distance = distance
end
@@ -77,15 +79,18 @@ end
local function connect()
while true do
if os.epoch("utc") - last_heartbeat > 200 then
canidate = {id = -1, distance = max_distance}
if os.epoch("utc") - last_heartbeat > math.max((300*canidate.distance)/100,300) then
canidate = {id = -1, distance = 764, max_distance=0}
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
function ()
while true do
local _, _, channel, _, msg, distance = pullEvent("modem_message")
if channel == 15125 then
if msg.protocol == "entrypoint_advertise" then
if distance < canidate.distance then
if distance > (msg.max_distance or 128) then
modem.transmit(15125,15125,{protocol="out_of_range",sender=os.getComputerID(),target=msg.sender})
elseif distance < canidate.distance then
canidate.max_distance = msg.max_distance
canidate.id = msg.sender
canidate.distance = distance
end
@@ -96,8 +101,12 @@ local function connect()
if canidate.id == -1 then
sleep(5)
else
modem.transmit(15125,15125,{protocol="entrypoint_connect",sender=os.getComputerID(),target=canidate.id})
last_heartbeat = os.epoch("utc")
if canidate.distance > (canidate.max_distance or 128) then
modem.transmit(15125,15125,{protocol="out_of_range",sender=os.getComputerID(),target=canidate.id})
else
modem.transmit(15125,15125,{protocol="entrypoint_connect",sender=os.getComputerID(),target=canidate.id})
last_heartbeat = os.epoch("utc")
end
end
else
local msg = table.remove(message_queue,1)
@@ -108,5 +117,8 @@ local function connect()
sleep()
end
end
function _G.network.getCandidate()
return canidate
end
parallel.waitForAny(receive, connect,function () shell.run("shell") end)
os.shutdown()

2045
lua-minify.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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,8 @@
local interactions = {}
local radio = peripheral.find("radio_tower")
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
local max_distance = 128
local distancemap = {}
local clients = {}
local message_queue = {}
@@ -48,6 +50,8 @@ local function entrypoint_recieving(channel, msg)
print("No route to",msg.destination)
end
end
elseif msg.protocol == "out_of_range" then
print("readjusting range")
end
end
end
@@ -84,6 +88,8 @@ if radio and modem 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
elseif data[1] == "modem_message" then
print(data[6])
max_distance = math.max(data[6] or 0,max_distance)
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
entrypoint_recieving(data[3], data[5])
@@ -107,6 +113,7 @@ elseif modem then
local data = {[5]={_target=-1}}
while true do
data = {os.pullEvent("modem_message")}
max_distance = math.max(data[6] or 0,max_distance)
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
entrypoint_recieving(data[3], data[5])
@@ -236,7 +243,7 @@ local function heartbeat_f()
end
local function entrypoint_advertising()
while true do
modem.transmit(15125,15125,{protocol="entrypoint_advertise",sender=os.getComputerID()})
modem.transmit(15125,15125,{protocol="entrypoint_advertise",sender=os.getComputerID(),max_distance=max_distance-10})
sleep(0.1)
end
end
@@ -249,7 +256,7 @@ local function healthcheck()
sleep(0.1)
end, function()
while not heartbeat_entrypoint do
modem.transmit(15125,15125,{protocol="heartbeat",sender=os.getComputerID(),target=client})
modem.transmit(15125,15125,{protocol="heartbeat",sender=os.getComputerID(),target=client,max_distance=max_distance-10})
sleep()
end
end)

File diff suppressed because one or more lines are too long