Update entrypointclient.lua
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
local max_distance = {}
|
llocal max_distance = {}
|
||||||
|
|
||||||
local pullEvent = os.pullEventRaw
|
local pullEvent = os.pullEventRaw
|
||||||
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)
|
||||||
@@ -37,9 +37,9 @@ local function receive()
|
|||||||
if msg.protocol == "heartbeat" and msg.target == os.getComputerID() and msg.sender == canidate.id then
|
if msg.protocol == "heartbeat" and msg.target == os.getComputerID() and msg.sender == canidate.id then
|
||||||
last_heartbeat = os.epoch("utc")
|
last_heartbeat = os.epoch("utc")
|
||||||
modem.transmit(15125,15125,{protocol="heartbeat_response",sender=os.getComputerID(),target=canidate.id})
|
modem.transmit(15125,15125,{protocol="heartbeat_response",sender=os.getComputerID(),target=canidate.id})
|
||||||
if distance > (max_distance[msg.sender]or 6)-5 then
|
if distance > (max_distance[msg.sender]or 764) then
|
||||||
modem.transmit(15125,15125,{protocol="entrypoint_disconnect",sender=os.getComputerID(),target=canidate.id})
|
modem.transmit(15125,15125,{protocol="entrypoint_disconnect",sender=os.getComputerID(),target=canidate.id})
|
||||||
canidate = {id = -1, distance = (max_distance[msg.sender]or 6)-5}
|
canidate = {id = -1, distance = (max_distance[msg.sender]or 764)}
|
||||||
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
||||||
function ()
|
function ()
|
||||||
while true do
|
while true do
|
||||||
@@ -79,7 +79,7 @@ end
|
|||||||
local function connect()
|
local function connect()
|
||||||
while true do
|
while true do
|
||||||
if os.epoch("utc") - last_heartbeat > 200 then
|
if os.epoch("utc") - last_heartbeat > 200 then
|
||||||
canidate = {id = -1, distance = (max_distance[msg.sender]or 6)-5}
|
canidate = {id = -1, distance = 764}
|
||||||
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
parallel.waitForAny(function () repeat sleep(0.1) until canidate.id ~= -1 end,
|
||||||
function ()
|
function ()
|
||||||
while true do
|
while true do
|
||||||
|
|||||||
Reference in New Issue
Block a user