Guest User

Untitled

a guest
Feb 28th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. function fuel()
  2. while true do
  3. if turtle.getFuelLevel() < 50 then
  4. print("current fuel is " ..turtle.getFuelLevel().. " need 50+")
  5. print("Please insert fuel source in slot 1")
  6. for i=1, 16 do
  7. turtle.select(i)
  8. turtle.refuel()
  9. end
  10. break
  11. else
  12. break
  13. end
  14. end
  15. end
  16.  
  17.  
  18.  
  19. function clear()
  20. term.clear()
  21. term.setCursorPos(1,1)
  22. end
  23.  
  24. function vDig()
  25. local goDown = 0
  26. local goUp
  27.  
  28. repeat
  29. goUp = 0
  30. while turtle.detectUp() do
  31. turtle.dig()
  32. goUp = goUp + 1
  33. end
  34.  
  35. for i=1,goUp do
  36. while not turtle.up() do turtle.attackUp() end
  37. goDown = goDown + 1
  38. end
  39. until not turtle.detectUp()
  40.  
  41. for i=1,goDown do
  42. while not turtle.down() do turtle.attackDown() end
  43. end
  44. end
  45.  
  46. function go()
  47. while not turtle.forward() do
  48. fuel()
  49. turtle.dig()
  50. turtle.attack()
  51. sleep(.5)
  52. end
  53. vDig()
  54. end
  55.  
  56. function forward()
  57. for i=1, x do
  58. if turtle.detectDown() == false then
  59. turtle.select(2)
  60. turtle.placeDown()
  61. else
  62. go()
  63. end
  64. end
  65. end
  66.  
  67.  
  68.  
  69.  
  70. term.write("How many blocks forward? ")
  71. x = tonumber(io.read())
  72. clear()
  73.  
  74. while true do
  75. print("Do you want the turtle to turn")
  76. print("Right or Left? R/L ")
  77. local event, param1 = os.pullEvent ("char")
  78. if param1 == "l" then
  79. print(" You chose Left! ")
  80. direction = "Left"
  81.  
  82. sleep(2)
  83. break
  84.  
  85. elseif param1 == "r" then
  86. print("You chose Right! ")
  87. direction = "Right"
  88. sleep(2)
  89. break
  90. else
  91. print ("Not valid!")
  92. sleep(1.5)
  93. clear()
  94. end
  95. end
  96.  
  97. clear()
  98.  
  99. print("How many blocks to the " ..direction)
  100. print("do you want to go? ")
  101. y = tonumber(io.read())
  102.  
  103.  
  104.  
  105. clear()
  106. print("Checking fuel...")
  107. sleep(2)
  108. fuel()
  109. sleep(2)
  110.  
  111.  
  112. if direction == "Left" then
  113. print("Starting! Left! ")
  114. else
  115. print("Starting! Right!")
  116. end
  117. for i=1,y do
  118. forward()
  119.  
  120. if i < y then
  121. if direction == "Left" then
  122. turtle.turnLeft()
  123. go()
  124. turtle.turnLeft()
  125. direction = "Right"
  126. else
  127. turtle.turnRight()
  128. go()
  129. turtle.turnRight()
  130. direction = "Left"
  131. end
  132. end
  133. end
  134.  
  135. clear()
Advertisement
Add Comment
Please, Sign In to add comment