Advertisement
PancakePhD

Miner

Apr 9th, 2020 (edited)
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tunnelLength = 100
  2. buffer = 2
  3. tunnels = 10
  4. placeTorches = true
  5. blocksBetweenTorches = 10
  6. autoRefuel = true
  7. startLeft = false
  8.  
  9. trash = {
  10.     dirt = true,
  11.     cobblestone = true,
  12.     stone = true,
  13.     gravel = true,
  14.     quartz = true,
  15.     resource = true,
  16.     nugget = true,
  17.     redstone = true,
  18.     iron_ore = true,
  19.     flint = true
  20. }
  21.  
  22. local function check()
  23.     for i=2,15 do
  24.         item = turtle.getItemDetail(i)
  25.         if item ~= nil then
  26.             print("Item: "..item.name)
  27.             print(trash[item.name])
  28.            
  29.             colon = string.find(item.name, ":")
  30.            
  31.             if trash[string.sub(item.name, colon + 1)] ~= nil and item.count > 0 then
  32.                 print("That's trash, throw it out")
  33.                 turtle.select(i)
  34.                 turtle.dropDown()
  35.             elseif item.name == "minecraft:coal" and autoRefuel then
  36.                 if turtle.getItemDetail(1).name == "minecraft:coal" then
  37.                     turtle.transferTo(1, item.count)
  38.                 end
  39.            
  40.                 if turtle.getFuelLevel() < 50 then
  41.                     turtle.select(1)
  42.                     turtle.refuel()
  43.                 end
  44.             elseif item.name == "minecraft:torch" then
  45.                 turtle.transferTo(16, turtle.getItemCount(i))            
  46.             end
  47.         end
  48.     end
  49.    
  50.     os.setComputerLabel("Fuel: "..turtle.getFuelLevel())
  51.     turtle.select(1)
  52. end
  53.  
  54. local function height()
  55.     turtle.dig()
  56.     turtle.digUp()
  57.     turtle.digDown()
  58.    
  59.     isBlock, block = turtle.inspect()
  60.    
  61.     if isBlock and block.name == "minecraft:gravel" then
  62.         height()
  63.     end
  64. end
  65.  
  66. local function length()
  67.     for i=1,tunnelLength do
  68.         height()
  69.        
  70.         if (i % (blocksBetweenTorches + 1)) == 0 and placeTorches and turtle.getItemDetail(16) ~= nil and turtle.getItemDetail(16).name == "minecraft:torch" then
  71.             turtle.select(16)
  72.             turtle.placeDown()
  73.             turtle.select(2)
  74.         end
  75.        
  76.         if i % 15 == 0 then
  77.             check()
  78.         end
  79.        
  80.         turtle.forward()
  81.     end
  82. end
  83.  
  84. local function main()
  85.     for k=1,tunnels do
  86.         length()
  87.        
  88.         if startLeft then
  89.             turtle.turnLeft()
  90.         else
  91.             turtle.turnRight()
  92.         end
  93.  
  94.         for k=1,buffer + 1 do
  95.             height()
  96.             turtle.forward()
  97.         end
  98.        
  99.         if startLeft then
  100.             turtle.turnLeft()
  101.             startLeft = false
  102.         else
  103.             turtle.turnRight()
  104.             startLeft = true
  105.         end
  106.     end
  107. end
  108.  
  109. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement