In the program that my mining turtles run, I save to file their x,y,z and direction. Every time they move or turn.
The idea is that, in case the chunk is unloaded and the turtles shut off, when the chunk is reloaded, they know how to return how to return home and aren't lost in the world. (I haven't written a GPS.)
In general, this works fine. The location is recorded accurately and the turtles return precisely home if they get rebooted through chunk loading.
However, I've found that sometimes the direction isn't recorded correctly and the turtles get even more lost! I'm really stumped by this.
function turnRight() turtle.turnRight() curPos.d = curPos.d + 1 if curPos.d > 3 then curPos.d = curPos.d - 4 end savePosition(curPos) end
Likely the chunk is unloaded between the actual turn and the saving to file, but with the saving of the position is so close to the actual turn, I'm not sure how to improve on this.











