diff --git a/turtle.lua b/turtle.lua index 398e071..e92495b 100644 --- a/turtle.lua +++ b/turtle.lua @@ -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