Advertisement
Speikobra099

Mining Program Turtle

Nov 20th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. running = false
  2.  
  3. sleepTime = 4
  4.  
  5. function placeLoader()
  6. selectedCh = turtle.getSelectedSlot()
  7. turtle.select(5)
  8. if turtle.getItemCount() == 0 then
  9. turtle.select(6)
  10. turtle.transferTo(5)
  11. turtle.select(5)
  12. end
  13. turtle.placeUp()
  14. turtle.select(selectedCh)
  15. end
  16.  
  17. function checkOn()
  18. turtle.turnLeft()
  19. turtle.turnLeft()
  20. digIt(3)
  21. selectedC = turtle.getSelectedSlot()
  22. turtle.select(14)
  23. turtle.place()
  24.  
  25. turtle.select(13)
  26. turtle.suck()
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. if turtle.getItemCount() == 0 then
  30. running = false
  31. print ("Not Running")
  32. else
  33. sleepTime = turtle.getItemCount()
  34. running = true
  35. print (sleepTime.."s sleepTime")
  36. end
  37. turtle.drop()
  38.  
  39. turtle.select(14)
  40. turtle.dig()
  41. turtle.select(selectedC)
  42. turtle.turnLeft()
  43. turtle.turnLeft()
  44. end
  45.  
  46. function digIt(slotToUse)
  47. selected = turtle.getSelectedSlot()
  48. turtle.select(slotToUse)
  49. repeat
  50. turtle.dig()
  51. turtle.dropDown()
  52. sleep(0.5)
  53. until turtle.detect() == false
  54. turtle.select(selected)
  55. end
  56.  
  57. print (sleepTime.."s sleepTime")
  58.  
  59. function digItDown(slotToUse)
  60. selected = turtle.getSelectedSlot()
  61. turtle.select(slotToUse)
  62. repeat
  63. turtle.digDown()
  64. turtle.dropDown()
  65. sleep(0.5)
  66. until turtle.detectDown() == false
  67. turtle.select(selected)
  68. end
  69.  
  70. function digItUp(slotToUse)
  71. selected = turtle.getSelectedSlot()
  72. turtle.select(slotToUse)
  73. repeat
  74. turtle.digUp()
  75. turtle.dropDown()
  76. sleep(0.5)
  77. until turtle.detectUp() == false
  78. turtle.select(selected)
  79. end
  80.  
  81. function refuelIt()
  82. if turtle.getFuelLevel() <= 16 then
  83. selectedF = turtle.getSelectedSlot()
  84. turtle.select(16)
  85. if turtle.getItemCount() == 0 then
  86. digItUp(3)
  87. turtle.select(15)
  88. turtle.placeUp()
  89. turtle.select(16)
  90. turtle.suckUp()
  91. turtle.select(15)
  92. turtle.digUp()
  93. turtle.select(16)
  94. end
  95. turtle.refuel(10)
  96. turtle.select(selectedF)
  97. end
  98. end
  99.  
  100. function placeIt()
  101.  
  102. refuelIt()
  103.  
  104. turtle.select(2)
  105.  
  106. turtle.turnLeft()
  107. if turtle.detect() then
  108. digIt(3)
  109. end
  110. turtle.place()
  111.  
  112. turtle.turnRight()
  113. if turtle.detect() then
  114. digIt(3)
  115. end
  116. turtle.forward()
  117. digItUp(3)
  118. placeLoader()
  119. turtle.back()
  120. turtle.place()
  121.  
  122. turtle.turnRight()
  123. if turtle.detect() then
  124. digIt(3)
  125. end
  126. turtle.place()
  127.  
  128. turtle.select(5)
  129. turtle.digUp()
  130. turtle.select(1)
  131. while  turtle.up() == false do
  132. digItUp(3)
  133. end
  134. turtle.placeDown()
  135. turtle.turnLeft()
  136. end
  137.  
  138. function removeIt()
  139.  
  140. turtle.digDown()
  141. turtle.down()
  142.  
  143. turtle.turnLeft()
  144. turtle.dig()
  145.  
  146. turtle.turnRight()
  147. turtle.dig()
  148.  
  149. turtle.turnRight()
  150. turtle.dig()
  151.  
  152. turtle.turnLeft()
  153.  
  154. turtle.forward()
  155.  
  156. end
  157.  
  158.  
  159. sleep(5)
  160. checkOn()
  161.  
  162. while rs.getInput("top") == false do
  163. if running == true then
  164. placeIt()
  165. sleep(sleepTime)
  166. removeIt()
  167. else
  168. sleep(2)
  169. end
  170. checkOn()
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement