Advertisement
Guest User

mine.lua

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