Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1.  
  2. local args = {...}
  3.  
  4. -- Config to determine what the turtle should mine
  5. local config = {
  6. ["diamond"] = true,
  7. ["iron ore"] = true,
  8. ["misc"] = false,
  9. }
  10.  
  11. local minFuelLevel = 200
  12. local torchSlot = 1
  13. local fuelSlot = 2
  14. local chestSlot = 3
  15.  
  16. local function initialize()
  17. print("Starting turtle...")
  18. print("Torches set to slot "..torchSlot)
  19. print("Fuel set to slot "..fuelSlot)
  20. end
  21.  
  22. local function digUp()
  23. while turtle.detectUp() do
  24. turtle.digUp()
  25. end
  26. end
  27.  
  28. local function digDown()
  29. while turtle.detectDown() do
  30. turtle.digDown()
  31. end
  32. end
  33.  
  34. local function dig()
  35. while turtle.detect() do
  36. turtle.dig()
  37. end
  38. end
  39.  
  40. local function forward()
  41. while not turtle.forward() do
  42. dig()
  43. end
  44. end
  45.  
  46. local function up()
  47. while not turtle.up() do
  48. digUp()
  49. end
  50. end
  51.  
  52. local function down()
  53. while not turtle.down() do
  54. digDown()
  55. end
  56. end
  57.  
  58. local function aboutFace()
  59. turtle.turnLeft()
  60. turtle.turnLeft()
  61. end
  62.  
  63. local function checkFuelLevel()
  64.  
  65. local fuelLevel = turtle.getFuelLevel()
  66.  
  67. if fuelLevel < minFuelLevel then
  68. turtle.select(fuelSlot)
  69. turtle.refuel(1)
  70. print("Refuelling... fuel level is now "..turtle.getFuelLevel())
  71. end
  72. end
  73.  
  74. local function placeChest()
  75. -- Place a chest behind the turtle
  76. turtle.select(chestSlot)
  77. dig()
  78. turtle.place()
  79.  
  80. for i = 4, 16 do
  81. turtle.drop()
  82. end
  83. end
  84.  
  85. local function mineAboutMine()
  86. dig()
  87. turtle.turnLeft()
  88. turtle.turnLeft()
  89. dig()
  90. end
  91.  
  92. local function doStripMine()
  93.  
  94. local stripLength = 3
  95.  
  96. checkFuelLevel()
  97.  
  98. ------------------------------------
  99. -- STARTING FROM MIDDLE, GO UP THEN MINE DOWN
  100. ------------------------------------
  101. up()
  102.  
  103. for i=1, stripLength / 2 do
  104.  
  105. checkFuelLevel()
  106.  
  107. -- Mine top layer, finish looking right
  108. turtle.turnLeft()
  109. dig()
  110. aboutFace()
  111. dig()
  112.  
  113. if (i % 7) == 0 then
  114. turtle.select(torchSlot)
  115. turtle.place()
  116. end
  117.  
  118. -- Mine middle layer, finish looking left
  119. down()
  120. dig()
  121. aboutFace()
  122. dig()
  123.  
  124. -- Mine bottom layer, finish looking right
  125. down()
  126. dig()
  127. aboutFace()
  128. dig()
  129.  
  130. -- Go forwards to start mining the next layer
  131. turtle.turnLeft()
  132. forward()
  133.  
  134. ------------------------------------
  135. -- STARTING FROM BOTTOM, MINE UP TO THE TOP
  136. ------------------------------------
  137.  
  138. -- Mine bottom layer, finish looking right
  139. turtle.turnLeft()
  140. dig()
  141. aboutFace()
  142. dig()
  143.  
  144. -- Mine middle layer, finish looking left
  145. up()
  146. dig()
  147. aboutFace()
  148. dig()
  149.  
  150. -- Mine top layer, finish looking forward
  151. up()
  152. dig()
  153. aboutFace()
  154. dig()
  155. turtle.turnLeft()
  156. end
  157.  
  158. turtle.down()
  159. turtle.turnLeft()
  160. turtle.turnLeft()
  161.  
  162. for i=1, stripLength do
  163. turtle.forward()
  164. end
  165.  
  166. placeChest()
  167. end
  168.  
  169. for i=1, 10 do
  170. doStripMine()
  171.  
  172. turtle.turnLeft()
  173.  
  174. for j=1, 6 do
  175. forward()
  176. digUp()
  177. digDown()
  178. end
  179.  
  180. turtle.turnLeft()
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement