Advertisement
Guest User

mine.lua

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