Update meshrouterentrypoint.lua
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
local interactions = {}
|
local interactions = {}
|
||||||
local radio = peripheral.find("radio_tower")
|
local radio = peripheral.find("radio_tower")
|
||||||
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
|
local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end)
|
||||||
|
|
||||||
|
local max_distance = 128
|
||||||
local distancemap = {}
|
local distancemap = {}
|
||||||
local clients = {}
|
local clients = {}
|
||||||
local message_queue = {}
|
local message_queue = {}
|
||||||
@@ -82,8 +84,9 @@ if radio and modem then
|
|||||||
local data = {os.pullEvent()}
|
local data = {os.pullEvent()}
|
||||||
if data[1] == "radio_message" then
|
if data[1] == "radio_message" then
|
||||||
data[3] = textutils.unserialise(data[3])
|
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
|
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[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
|
if data[3] == 15125 then
|
||||||
entrypoint_recieving(data[3], data[5])
|
entrypoint_recieving(data[3], data[5])
|
||||||
@@ -236,7 +239,7 @@ local function heartbeat_f()
|
|||||||
end
|
end
|
||||||
local function entrypoint_advertising()
|
local function entrypoint_advertising()
|
||||||
while true do
|
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)
|
sleep(0.1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -249,7 +252,7 @@ local function healthcheck()
|
|||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
end, function()
|
end, function()
|
||||||
while not heartbeat_entrypoint do
|
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()
|
sleep()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user