Advertisement
Testman696969

Miner

Dec 13th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. length=100
  2. current=0
  3. barrels={
  4. "minecraft:cobblestone",
  5. "minecraft:stone",
  6. "minecraft:dirt",
  7. "minecraft:gravel"
  8. }
  9.  
  10. function Dig()
  11. local success,data=turtle.inspect()
  12. if success and not (data.name=="computercraft:turtle_expanded") then
  13. while turtle.detect() do
  14. turtle.dig()
  15. end
  16. end
  17. end
  18.  
  19. function DigUp()
  20. local success,data=turtle.inspectUp()
  21. if success and not (data.name=="computercraft:turtle_expanded") then
  22. turtle.digUp()
  23. end
  24. end
  25.  
  26. function DigDown()
  27. local success,data=turtle.inspectDown()
  28. if success then
  29. if data.name=="minecraft:bedrock" then return false
  30. elseif data.name=="computercraft:turtle_expanded" then
  31. elseif data.name=="minecraft:log" then
  32. while data.name=="minecraft:log" do
  33. success,data=turtle.inspectDown()
  34. end
  35. else turtle.digDown()
  36. end
  37. end
  38. return true
  39. end
  40.  
  41. function Forward()
  42. while not turtle.forward() do
  43. Dig()
  44. turtle.attack()
  45. end
  46. end
  47.  
  48. function Up()
  49. while not turtle.up() do
  50. DigUp()
  51. turtle.attackUp()
  52. end
  53. end
  54.  
  55. function Down()
  56. while not turtle.down() do
  57. DigDown()
  58. turtle.attackDown()
  59. end
  60. end
  61.  
  62. function Dump()
  63. local success,data=turtle.inspect()
  64. if success and data.name=="minecraft:chest" then
  65. else
  66. while not (data.name=="minecraft:chest") do
  67. success,data=turtle.inspect()
  68. end
  69. end
  70. for slot=1,16 do
  71. turtle.select(slot)
  72. while not turtle.drop() do turtle.drop() end
  73. end
  74. turtle.select(1)
  75. end
  76.  
  77. function CheckWorth(obj)
  78. for i=1,#barrels do
  79. if obj==barrels[i] then return false end
  80. end
  81. return true
  82. end
  83.  
  84. function DigIfWorth()
  85. local success,data=turtle.inspect()
  86. if success and CheckWorth(data.name) then Dig() end
  87. end
  88.  
  89. function DigFace()
  90. turtle.turnLeft()
  91. DigIfWorth()
  92. local depth=0
  93. while DigDown() do
  94. Down()
  95. DigIfWorth()
  96. depth=depth+1
  97. end
  98. turtle.turnRight() turtle.turnRight()
  99. DigIfWorth()
  100. for i=1,depth do
  101. Up()
  102. DigIfWorth()
  103. end
  104. turtle.turnLeft()
  105. end
  106.  
  107. function EmptyInventory(dist)
  108. turtle.turnRight() turtle.turnRight()
  109. while current>0 do
  110. Forward()
  111. current=current-1
  112. end
  113. Down() Down() Down()
  114. Dump()
  115.  
  116. turtle.turnRight() turtle.turnRight()
  117. Up() Up() Up()
  118.  
  119. while current<dist do
  120. Forward()
  121. current=current+1
  122. end
  123. end
  124.  
  125. function DigTunnel()
  126. while current<length do
  127. DigFace()
  128. Dig()
  129. Forward()
  130. current=current+1
  131. if turtle.getItemCount(16)>0 then EmptyInventory(current) end
  132. end
  133. EmptyInventory(0)
  134. end
  135.  
  136. function FindPosition()
  137. turtle.turnLeft()
  138. while not (turtle.detect()) do
  139. turtle.forward()
  140. end
  141. local success,data=turtle.inspect()
  142. if success and not (data.name=="computercraft:turtle_expanded") then
  143. Dig() Forward()
  144. Dig() Forward()
  145. Dig() Forward()
  146. turtle.turnRight()
  147. DigTunnel()
  148. else
  149. turtle.turnRight() sleep(2)
  150. end
  151. end
  152.  
  153.  
  154.  
  155. while true do
  156. FindPosition()
  157. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement