Update meshrouterentrypoint.lua

This commit is contained in:
2025-12-24 23:16:15 +00:00
parent 8eb9766874
commit 52afc41061

View File

@@ -50,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
@@ -86,6 +88,7 @@ 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
@@ -110,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])
@@ -239,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(),max_distance=max_distance})
modem.transmit(15125,15125,{protocol="entrypoint_advertise",sender=os.getComputerID(),max_distance=max_distance-10})
sleep(0.1)
end
end
@@ -252,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,max_distance=max_distance})
modem.transmit(15125,15125,{protocol="heartbeat",sender=os.getComputerID(),target=client,max_distance=max_distance-10})
sleep()
end
end)