feat: Add error handling for turtle startup script and improve GPS retry logic
This commit is contained in:
17
turtle.lua
17
turtle.lua
@@ -965,12 +965,17 @@ print("Turtle " .. os.getComputerID() .. " is online!")
|
||||
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
|
||||
while true do
|
||||
if not state.position then
|
||||
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
|
||||
else
|
||||
-- Once we have position, just sleep to keep this thread alive
|
||||
sleep(30)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
Reference in New Issue
Block a user