Advertisement
TechEdison

Untitled

Feb 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. local min_empty = 1 -- The least amount of free slots before inv is regarded as full
  2.  
  3. local FUEL = 1
  4. local TORCH = 2
  5. local FREE = 3
  6.  
  7. local torch_interval = 6
  8. local torch_current = 1
  9. local pos_total = 0
  10. local pos_current = 0
  11.  
  12. term.clear()
  13. term.setCursorPos(1, 1)
  14.  
  15. function torch()
  16. torching = true
  17. turtle.select(TORCH)
  18. turtle.turnLeft()
  19. turtle.place()
  20. turtle.turnRight()
  21. torching = false
  22. end
  23.  
  24. function full_inv()
  25. if turtle.getItemCount(16) > 0 then
  26. return true
  27. end
  28. end
  29.  
  30. function empty_inv()
  31. for i=FREE,16 do
  32. turtle.select(i)
  33. turtle.dropUp()
  34. end
  35. end
  36.  
  37. function refuel()
  38. -- This beast is designed to run on coal
  39. if turtle.getFuelLevel() <= 20 then
  40. turtle.select(FUEL)
  41. return turtle.refuel(1)
  42. end
  43. return true
  44. end
  45.  
  46. function mine_chunk()
  47. print("Mining chunk nr: ")
  48. print(pos_current)
  49.  
  50. while turtle.detect() do
  51. turtle.dig()
  52. end
  53. turtle.forward()
  54.  
  55. pos_current = pos_current + 1
  56. pos_total = pos_total + 1
  57. torch_current = torch_current + 1
  58.  
  59. while turtle.detectUp() do
  60. turtle.digUp()
  61. end
  62. turtle.up()
  63. while turtle.detectUp() do
  64. turtle.digUp()
  65. end
  66. turtle.down()
  67. turtle.turnLeft()
  68. while turtle.detect() do
  69. turtle.dig()
  70. end
  71. turtle.forward()
  72. turtle.turnRight()
  73.  
  74. while turtle.detectUp() do
  75. turtle.digUp()
  76. end
  77. turtle.up()
  78. while turtle.detectUp() do
  79. turtle.digUp()
  80. end
  81. turtle.down()
  82. turtle.turnLeft()
  83. while turtle.detect() do
  84. turtle.dig()
  85. end
  86. turtle.forward()
  87. turtle.turnRight()
  88.  
  89. while turtle.detectUp() do
  90. turtle.digUp()
  91. end
  92. turtle.up()
  93. while turtle.detectUp() do
  94. turtle.digUp()
  95. end
  96. turtle.down()
  97. turtle.turnLeft()
  98. while turtle.detect() do
  99. turtle.dig()
  100. end
  101. turtle.forward()
  102. turtle.turnRight()
  103.  
  104. while turtle.detectUp() do
  105. turtle.digUp()
  106. end
  107. turtle.up()
  108. while turtle.detectUp() do
  109. turtle.digUp()
  110. end
  111. turtle.down()
  112.  
  113. turtle.turnRight()
  114. turtle.forward()
  115. turtle.forward()
  116. turtle.forward()
  117. turtle.turnLeft()
  118.  
  119. print("Mined chunk nr: ")
  120. print(pos_current)
  121. end
  122.  
  123. function return_and_empty()
  124. print("Emptying...")
  125.  
  126. while pos_current ~= 0 do
  127.  
  128. turtle.back()
  129. pos_current = pos_current - 1
  130.  
  131. end
  132.  
  133. empty_inv()
  134.  
  135. while pos_current ~= pos_total do
  136.  
  137. turtle.forward()
  138. pos_current = pos_current + 1
  139.  
  140. end
  141.  
  142. print("Emptied. Returning")
  143. end
  144.  
  145. function main_loop()
  146. -- refuel()
  147. mine_chunk()
  148.  
  149. if full_inv() == true then
  150. return_and_empty()
  151. end
  152.  
  153. if torch_current == torch_interval then
  154. torch()
  155. torch_current = 1
  156. end
  157.  
  158. main_loop()
  159. end
  160.  
  161. print("Starting the tunnel")
  162. main_loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement