Update meshrouterentrypoint.lua

This commit is contained in:
2025-12-24 22:29:55 +00:00
parent 464b692f69
commit 9820bd4fa0

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 = {}
@@ -82,8 +84,9 @@ 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 and data[4] < 2611 then return data[2], data[3], data[4] end
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
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 +239,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})
sleep(0.1)
end
end
@@ -249,7 +252,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})
sleep()
end
end)