fix: Add GPS retry mechanism for turtles without initial position
This commit is contained in:
16
turtle.lua
16
turtle.lua
@@ -932,6 +932,10 @@ if x then
|
|||||||
else
|
else
|
||||||
print("GPS: Not available - will retry in background")
|
print("GPS: Not available - will retry in background")
|
||||||
print("Position tracking disabled for now.")
|
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
|
end
|
||||||
|
|
||||||
-- Sync state with server
|
-- Sync state with server
|
||||||
@@ -951,6 +955,18 @@ print("Turtle " .. os.getComputerID() .. " is online!")
|
|||||||
|
|
||||||
-- Main execution loop
|
-- Main execution loop
|
||||||
parallel.waitForAny(
|
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()
|
function()
|
||||||
-- Status broadcast loop
|
-- Status broadcast loop
|
||||||
while true do
|
while true do
|
||||||
|
|||||||
Reference in New Issue
Block a user