Advertisement
Guest User

goto

a guest
Nov 27th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1.  
  2.  
  3. local xCord, yCord, zCord = gps.locate()
  4.  
  5. local direction = ""
  6.  
  7. term.clear()
  8. term.setCursorPos(1,1)
  9.  
  10. print("CALIBRATE:")
  11. print("Pose a block at the NORTH of the EcTurtle.")
  12. print("Type something to start calibrate")
  13. read()
  14.  
  15.  
  16. function GoTo()
  17. print("Current position:")
  18. print(" x: " ..xCord)
  19. print(" y: " ..yCord)
  20. print(" z: " ..zCord)
  21.  
  22. print("Go to position")
  23. print("x:")
  24. local x = read()
  25.  
  26. print("y:")
  27. local y = read()
  28.  
  29. print("z:")
  30. local z = read()
  31.  
  32. if xCord < 0 then
  33. xC = 0 - xCord
  34. end
  35.  
  36. if yCord < 10 then
  37. yC = 10
  38. end
  39.  
  40. if zCord < 0 then
  41. xC = 0 - zCord
  42. end
  43.  
  44. if tonumber(x) < 0 then
  45. direction = "west"
  46. turtle.turnLeft()
  47. for i=0,xC do
  48. if turtle.detect() == true then
  49. turtle.dig()
  50. turtle.forward()
  51. sleep(0.5)
  52. else
  53. turtle.forward()
  54. sleep(0.5)
  55. end
  56. end
  57. turtle.turnRight()
  58. else
  59. direction = "east"
  60. turtle.turnRight()
  61. for i3 = 0,xC do
  62. if turtle.detect() == true then
  63. turtle.dig()
  64. turtle.forward()
  65. sleep(0.5)
  66. else
  67. turtle.forward()
  68. sleep(0.5)
  69. end
  70. end
  71. turtle.turnLeft();
  72. end
  73.  
  74. if tonumber(y) < yCord then
  75. direction = "down"
  76. for i1=0,yC do
  77. if turtle.detect() == true then
  78. turtle.digDown()
  79. turtle.down()
  80. sleep(0.5)
  81. else
  82. turtle.down()
  83. sleep(0.5)
  84. end
  85. end
  86. else
  87. direction = "up"
  88. for i2=0,yC do
  89. if turtle.detectUp() == true then
  90. turtle.digUp()
  91. turtle.up()
  92. sleep(0.5)
  93. else
  94. turtle.up()
  95. sleep(0.5)
  96. end
  97. end
  98. end
  99. if tonumber(z) < 0 then
  100. direction = "north"
  101. turtle.turnLeft()
  102. for i=0,zC do
  103. if turtle.detect() == true then
  104. turtle.dig()
  105. turtle.forward()
  106. sleep(0.5)
  107. else
  108. turtle.forward()
  109. sleep(0.5)
  110. end
  111. end
  112. else
  113. direction = "south"
  114. turtle.turnRight()
  115. sleep(0.5)
  116. turtle.turnRight()
  117. for i3 = 0,zC do
  118. if turtle.detect() == true then
  119. turtle.dig()
  120. turtle.forward()
  121. sleep(0.5)
  122. else
  123. turtle.forward()
  124. sleep(0.5)
  125. end
  126. end
  127. end
  128. turtle.turnLeft()
  129. sleep(0.5)
  130. turtle.turnLeft()
  131. end
  132.  
  133.  
  134. if turtle.detect() == false then
  135. turtle.turnRight()
  136. else
  137. print("CALIBRATED.")
  138. direction = "north"
  139. GoTo()
  140. end
  141.  
  142. if turtle.detect() == false then
  143. turtle.turnRight()
  144. else
  145. print("CALIBRATED.")
  146. direction = "north"
  147. GoTo()
  148. end
  149.  
  150. if turtle.detect() == false then
  151. turtle.turnRight()
  152. else
  153. print("CALIBRATED.")
  154. direction = "north"
  155. GoTo()
  156. end
  157.  
  158. if turtle.detect() == false then
  159. print("NORTH NOT FOUND")
  160. print("restarting app...")
  161. else
  162. print("CALIBRATED.")
  163. direction = "north"
  164. GoTo()
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement