Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. running = true
  2. distance = 1
  3.  
  4. local function dropCobblestone()
  5. dropped = 0
  6. for i=16,3,-1 do
  7. turtle.select(i)
  8. amount = turtle.getItemCount()
  9.  
  10. if amount > 0 then
  11. data = turtle.getItemDetail()
  12.  
  13. if data.name == "minecraft:cobblestone" then
  14. turtle.drop()
  15. dropped = dropped + amount
  16. end
  17. end
  18.  
  19. end
  20.  
  21. if dropped > 128 then
  22. print("Dropped x" .. dropped .. " cobblestone.")
  23. end
  24.  
  25. end
  26.  
  27. local function alternativeFuel()
  28. print("No main fuel, trying alternative.")
  29.  
  30. for i=16,3,-1 do
  31. turtle.select(i)
  32.  
  33. amount = turtle.getItemCount(i)
  34.  
  35. if amount > 0 then
  36. data = turtle.getItemDetail(i)
  37. if data.name == "minecraft:coal" then
  38. turtle.refuel()
  39. print("Found coal alternative fuel.")
  40. end
  41.  
  42. end
  43.  
  44. end
  45.  
  46. if turtle.getFuelLevel() == 0 then
  47. print("No alternatives found, quitting.")
  48. running = false
  49. end
  50. end
  51.  
  52. local function depositItems()
  53. if turtle.getFuelLevel() <= distance then
  54. turtle.turnLeft()
  55. turtle.turnLeft()
  56.  
  57. for i=turtle.getFuelLevel(),0,-1 do
  58. turtle.forward()
  59.  
  60. success, data = turtle.inspect()
  61.  
  62. if success then
  63. if data.name == "minecraft:chest" then
  64. for o=16,3,-1 do
  65. turtle.select(o)
  66. turtle.drop()
  67. end
  68. else
  69. turtle.dig()
  70. end
  71. end
  72.  
  73. end
  74. end
  75. end
  76.  
  77. local function fuel()
  78. if turtle.getFuelLevel() == 0 then
  79. turtle.select(1)
  80. amount = turtle.getItemCount()
  81.  
  82. if amount > 0 then
  83. if data.name == "minecraft:bucket" then
  84. alternativeFuel()
  85. else if data.name == "minecraft:lava_bucket" then
  86. turtle.refuel()
  87. print("Refuelling.")
  88. else
  89. alternativeFuel()
  90. end
  91. end
  92. end
  93.  
  94. turtle.select(1)
  95.  
  96. end
  97. end
  98.  
  99. local function checkSide()
  100.  
  101. turtle.turnLeft()
  102.  
  103. success_left, data_left = turtle.inspect()
  104.  
  105. if success_left then
  106. if data_left.name == "minecraft:gold_ore" then
  107. turtle.dig()
  108. turtle.select(2)
  109. turtle.dig()
  110. turtle.select(1)
  111. end
  112.  
  113. if data_left.name == "minecraft:diamond_ore" then
  114. turtle.dig()
  115. turtle.select(2)
  116. turtle.dig()
  117. turtle.select(1)
  118. end
  119. end
  120.  
  121. turtle.turnRight()
  122. turtle.turnRight()
  123.  
  124. success_right, data_right = turtle.inspect()
  125.  
  126. if success_right then
  127. if data_right.name == "minecraft:gold_ore" then
  128. turtle.digRight()
  129. turtle.select(2)
  130. turtle.placeRight()
  131. turtle.select(1)
  132. end
  133.  
  134. if data_right.name == "minecraft:diamond_ore" then
  135. turtle.digRight()
  136. turtle.select(2)
  137. turtle.placeRight()
  138. turtle.select(1)
  139. end
  140. end
  141.  
  142. turtle.turnLeft()
  143.  
  144. end
  145.  
  146. local function mine()
  147.  
  148. fuel()
  149. -- checkSide()
  150.  
  151. turtle.dig()
  152. turtle.forward()
  153. distance = distance + 1
  154. turtle.digUp()
  155.  
  156. dropCobblestone()
  157.  
  158. success, data = turtle.inspectDown()
  159.  
  160. if not success then
  161. turtle.select(2)
  162. turtle.placeDown()
  163. turtle.select(1)
  164. end
  165.  
  166. if success then
  167. if data.name == "minecraft:flowing_lava" then
  168. turtle.select(1)
  169. data_item = turtle.getItemDetail(1)
  170.  
  171. if data_item.name == "minecraft:bucket" then
  172. turtle.place()
  173. data = turtle.getItemDetail()
  174. if data.name == "minecraft:lava_bucket" then
  175. print("Got more fuel!")
  176. if turtle.getFuelLevel() < 10000 then
  177. turtle.refuel()
  178. print(turtle.getFuelLevel())
  179. else
  180. print("Turtle is above 10,000 fuel units.")
  181. end
  182. end
  183. else
  184. print("Lava found, but bucket is full.")
  185. end
  186.  
  187. end
  188. end
  189.  
  190. end
  191.  
  192. local function tick()
  193. depositItems()
  194. mine()
  195. end
  196.  
  197. while running do
  198. tick()
  199.  
  200. if not running then
  201. print("The mining script has terminated.")
  202. end
  203. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement