Advertisement
Guest User

Return

a guest
Jun 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. print("Returning...")
  2.  
  3. hX = -723
  4. hY = 4
  5. hZ = -198
  6. trackingX = true
  7. trackingZ = true
  8. trackingY = false
  9. pathing = true
  10. fuelSlot = 1
  11. compareSlot = 2
  12.  
  13. turtle.select(fuelSlot)
  14. turtle.refuel()
  15. -- X-Coord
  16. while trackingX do
  17. x, y, z = gps.locate(10)
  18. turtle.forward()
  19. oX, oY, oZ = gps.locate(10)
  20. if not (math.abs(hX - oX) < math.abs(hX - x)) then
  21. turtle.back()
  22. turtle.turnLeft()
  23. if math.abs(hX - oX) == 0 then
  24. trackingX = false
  25. print("Located X value.")
  26. end
  27. end
  28. end
  29. -- Z-Coord
  30. while trackingZ do
  31. x, y, z = gps.locate(10)
  32. turtle.forward()
  33. oX, oY, oZ = gps.locate(10)
  34. if not (math.abs(hZ - oZ) < math.abs(hZ - z)) then
  35. turtle.back()
  36. turtle.turnLeft()
  37. if math.abs(hZ - oZ) == 0 then
  38. trackingZ = false
  39. print("Located Z value.")
  40. end
  41. end
  42. end
  43. -- Y-Coord -- WIP
  44. while trackingY do
  45. x, y, z = gps.locate(10)
  46. turtle.up()
  47. oX, oY, oZ = gps.locate(10)
  48. if not (math.abs(hY - oY) < math.abs(hY - y)) then
  49. turtle.down()
  50. if math.abs(hY - oY) == 0 then
  51. trackingY = false
  52. print("Located Y value.")
  53. end
  54. end
  55. end
  56. -- Pathing
  57. print("Running pathing program...")
  58. turtle.select(2)
  59. if (turtle.compareDown) then
  60. rotations = 0
  61. while pathing do
  62. turtle.forward()
  63. if (turtle.compareDown() == false) then
  64. turtle.back()
  65. if (rotations == 0) then
  66. turtle.turnLeft()
  67. elseif (rotations == 1) then
  68. turtle.turnRight()
  69. turtle.turnRight()
  70. elseif (rotations == 2) then
  71. turtle.turnLeft()
  72. print("Path ended.")
  73. pathing = false
  74. break
  75. end
  76. rotations = rotations + 1
  77. else
  78. rotations = 0
  79. end
  80. end
  81. else
  82. print("No path.")
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement