fix: Add GPS retry mechanism for turtles without initial position

This commit is contained in:
MayaTheShy
2026-02-19 23:42:06 -05:00
parent 856cf88a19
commit 43bba2ced7

View File

@@ -932,6 +932,10 @@ if x then
else
print("GPS: Not available - will retry in background")
print("Position tracking disabled for now.")
-- Initialize position to nil so we know we need GPS
state.position = nil
print("⚠️ WARNING: Without GPS, relative positioning will be inaccurate!")
print("⚠️ Please place GPS hosts or set home position manually.")
end
-- Sync state with server
@@ -951,6 +955,18 @@ print("Turtle " .. os.getComputerID() .. " is online!")
-- Main execution loop
parallel.waitForAny(
function()
-- GPS retry loop for turtles without initial position
while not state.position do
sleep(10) -- Try every 10 seconds
print("Retrying GPS...")
if updatePosition() then
print("✅ GPS acquired! Position:", textutils.serialize(state.position))
broadcastStatus() -- Send updated position immediately
end
end
end,
function()
-- Status broadcast loop
while true do