feat: Add error handling for turtle startup script and improve GPS retry logic

This commit is contained in:
MayaTheShy
2026-02-20 00:32:40 -05:00
parent 544c5be954
commit af2d120baa
2 changed files with 26 additions and 8 deletions

View File

@@ -34,8 +34,21 @@ if response then
print("Starting turtle program...") print("Starting turtle program...")
sleep(1) sleep(1)
-- Run the script -- Run the script with error handling
shell.run(SCRIPT_NAME) local success, error = pcall(function()
shell.run(SCRIPT_NAME)
end)
if not success then
print("")
print("========================================")
print(" ERROR OCCURRED!")
print("========================================")
print(error)
print("")
print("Press any key to see error details...")
os.pullEvent("key")
end
else else
print("✗ Download failed!") print("✗ Download failed!")
print("Please check:") print("Please check:")

View File

@@ -965,12 +965,17 @@ print("Turtle " .. os.getComputerID() .. " is online!")
parallel.waitForAny( parallel.waitForAny(
function() function()
-- GPS retry loop for turtles without initial position -- GPS retry loop for turtles without initial position
while not state.position do while true do
sleep(10) -- Try every 10 seconds if not state.position then
print("Retrying GPS...") sleep(10) -- Try every 10 seconds
if updatePosition() then print("Retrying GPS...")
print("✅ GPS acquired! Position:", textutils.serialize(state.position)) if updatePosition() then
broadcastStatus() -- Send updated position immediately 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 end
end, end,