From 52afc41061687529995ec2009de667590e67c914 Mon Sep 17 00:00:00 2001 From: Rivulet Date: Wed, 24 Dec 2025 23:16:15 +0000 Subject: [PATCH] Update meshrouterentrypoint.lua --- meshrouterentrypoint.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/meshrouterentrypoint.lua b/meshrouterentrypoint.lua index e081933..743087b 100644 --- a/meshrouterentrypoint.lua +++ b/meshrouterentrypoint.lua @@ -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)