From e1471df6a8a8c8d9b0b845b0164a9ec2108b5311 Mon Sep 17 00:00:00 2001 From: Rivulet Date: Sun, 5 Apr 2026 00:58:12 +0000 Subject: [PATCH] Update entrypointlib.lua --- entrypointlib.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/entrypointlib.lua b/entrypointlib.lua index a0526b9..9fe87f3 100644 --- a/entrypointlib.lua +++ b/entrypointlib.lua @@ -1,7 +1,5 @@ local pullEvent = os.pullEventRaw local modem = peripheral.find("modem",function (s) return peripheral.wrap(s).isWireless() end) -term.clear() -term.setCursorPos(1,1) local network = {} local message_queue = {} modem.open(15125) @@ -24,7 +22,7 @@ end) local last_heartbeat = os.epoch("utc") modem.transmit(15125,15125,{protocol="entrypoint_connect",sender=os.getComputerID(),target=canidate.id}) -local function receive() +function network.receive() while true do local _, _, channel, _, msg, distance = pullEvent("modem_message") if channel == 15125 then @@ -73,7 +71,7 @@ function network.send(msg,destination) message_queue[#message_queue+1] = {protocol="packet",content=msg,destination=destination,sender=os.getComputerID(),hops=0} end -local function connect() +function network.connect() while true do if os.epoch("utc") - last_heartbeat > math.max((300*canidate.distance)/100,300) then canidate = {id = -1, distance = 764, max_distance=0} @@ -116,9 +114,7 @@ end function network.getCandidate() return canidate end - function network.loop() - parallel.waitForAny(connect,receive) + parallel.waitForAll(network.connect,network.receive) end - return network