Guest User

syncpos

a guest
Oct 6th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local xIni, yIni, zIni
  2. local xCur, yCur, zCur
  3. local fCur
  4. local posOut
  5.  
  6. xIni, yIni, zIni = gps.locate(5)
  7.  
  8. if not xIni or not yIni or not zIni then
  9.   print("No or insufficient GPS hosts found")
  10.   close()
  11. end
  12.  
  13. while not turtle.forward() do
  14.   while not turtle.up() do
  15.     turtle.digUp()
  16.   end
  17. end
  18.  
  19. xCur, yCur, zCur = gps.locate(5)
  20. if zCur > zIni then
  21.   fCur = 0
  22. elseif xCur < xIni then
  23.   fCur = 1
  24. elseif zCur < zIni then
  25.   fCur = 2
  26. elseif xCur > xIni then
  27.   fCur = 3
  28. else
  29.   exit()
  30. end
  31.  
  32. while not turtle.back() do
  33.   while not turtle.up() do
  34.     turtle.digUp()
  35.   end
  36. end
  37.  
  38. xCur, yCur, zCur = gps.locate(5)
  39.  
  40. posOut = io.open("data/pos.txt", "w")
  41. posOut:write(textutils.serialize({xCur, yCur, zCur, fCur}))
  42. posOut:close()
Advertisement
Add Comment
Please, Sign In to add comment