Advertisement
Jaryt23

modified michael reeves quarry

Jan 5th, 2021 (edited)
3,539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.51 KB | None | 0 0
  1. local SLOT_COUNT = 16
  2. local d = "north"
  3. local width, depth, height = 10, 10, 2
  4.  
  5. if (#arg == 3) then
  6.     width = tonumber(arg[1])
  7.     depth = tonumber(arg[2])
  8.     height = tonumber(arg[3])
  9. else
  10.     print('None or Malformed Size Given, Defaulting to 10x10x2 up')
  11. end
  12.  
  13.  
  14. BLACK_LIST = {
  15.     "minecraft:stone",
  16.     "minecraft:dirt",
  17.     "minecraft:cobblestone",
  18.     "minecraft:sand",
  19.     "minecraft:granite",
  20.     "minecraft:andesite",
  21.     "minecraft:diorite",
  22.     "extcaves:sedimentstone",
  23.     "powah:dry_ice",
  24.     "extcaves:lavastone",
  25.     "create:weathered_limestone",
  26.     "astralsorcery:marble_raw",
  27.     "create:scoria",
  28.     "mana-and-artifice:vinteum_ore"
  29. }
  30.  
  31.  
  32. function getEnderIndex()
  33.     for slot = 1, SLOT_COUNT, 1 do
  34.         local item = turtle.getItemDetail(slot)
  35.         if(item ~= nil) then
  36.             if(item["name"] == "enderstorage:ender_chest") then
  37.                 return slot
  38.             end
  39.         end
  40.     end
  41.     return nil
  42. end
  43.  
  44. function manageInventory()
  45.     index = getEnderIndex()
  46.     if(index ~= nil) then
  47.         turtle.select(index)
  48.         turtle.digUp()      
  49.         turtle.placeUp()  
  50.     end
  51.     -- Chest is now deployed
  52.     local coalSlot = -1
  53.  
  54.     for slot = 1, SLOT_COUNT, 1 do
  55.         local item = turtle.getItemDetail(slot)
  56.  
  57.         if(item ~= nil) then
  58.             turtle.select(slot)
  59.            
  60.             if(item["name"] == "minecraft:coal") then
  61.                 if (coalSlot == -1) then
  62.                     coalSlot = slot
  63.                 else
  64.                     turtle.transferTo(coalSlot)
  65.                 end
  66.             end
  67.  
  68.             if (slot ~= coalSlot and slot ~= index) then
  69.                 turtle.dropUp()
  70.             end
  71.         end
  72.     end
  73.     -- Items are now stored
  74.  
  75.     turtle.digUp()
  76. end
  77.  
  78. function checkFuel()
  79.     turtle.select(1)
  80.  
  81.     if(turtle.getFuelLevel() < 50) then
  82.         print("Attempting Refuel...")
  83.         for slot = 1, SLOT_COUNT, 1 do
  84.             turtle.select(slot)
  85.             if(turtle.refuel(5)) then
  86.                 return true
  87.             end
  88.         end
  89.  
  90.         return false
  91.     else
  92.         return true
  93.     end
  94. end
  95.  
  96. function checkBlock(force, check, dig)
  97.     local name = select(2, check())["name"]
  98.     local shouldDig = true
  99.  
  100.     if (force == false) then
  101.         for filterIndex = 1, #BLACK_LIST, 1 do
  102.             if(name == BLACK_LIST[filterIndex]) then
  103.                 shouldDig = false
  104.             end
  105.         end
  106.     end
  107.  
  108.     if (shouldDig) then
  109.         dig()
  110.     end
  111. end
  112.  
  113.  
  114. function detectAndDig()
  115.     checkBlock(true, turtle.inspect, turtle.dig)
  116.     checkBlock(false, turtle.inspectUp, turtle.digUp)
  117.     checkBlock(false, turtle.inspectDown, turtle.digDown)
  118. end
  119.  
  120. function forward()
  121.     detectAndDig()
  122.     turtle.forward()
  123. end
  124.  
  125. function leftTurn()
  126.     turtle.turnLeft()
  127.     detectAndDig()
  128.     turtle.forward()
  129.     turtle.turnLeft()
  130.     detectAndDig()
  131. end
  132.  
  133.  
  134. function rightTurn()
  135.     turtle.turnRight()
  136.     detectAndDig()
  137.     turtle.forward()
  138.     turtle.turnRight()
  139.     detectAndDig()
  140. end
  141.  
  142. function flipDirection()
  143.     if(d == "north") then
  144.         d = "south"
  145.     elseif(d == "south") then
  146.         d = "north"
  147.     elseif(d == "west") then
  148.         d = "east"
  149.     elseif(d == "east") then
  150.         d = "west"
  151.     end
  152.  
  153. end
  154.  
  155. function turnAround(tier)
  156.     if(tier % 2 == 1) then
  157.         if(d == "north" or d == "east") then
  158.             rightTurn()
  159.         elseif(d == "south" or d == "west") then
  160.             leftTurn()
  161.         end
  162.     else
  163.         if(d == "north" or d == "east") then
  164.             leftTurn()
  165.         elseif(d == "south" or d == "west") then
  166.             rightTurn()
  167.         end
  168.     end
  169.     flipDirection()
  170. end
  171.  
  172.  
  173. function riseTier()
  174.     turtle.turnRight()
  175.     turtle.turnRight()
  176.     flipDirection()
  177.     turtle.digUp()
  178.     turtle.up()
  179.     turtle.digUp()
  180.     turtle.up()
  181.     turtle.digUp()
  182.     turtle.up()
  183. end
  184.  
  185.  
  186. function start()
  187.     turtle.digUp()
  188.     turtle.up()
  189.     for tier = 1, height, 1 do
  190.         for col = 1, width, 1 do
  191.             for row = 1, depth - 1, 1 do
  192.                 if(not checkFuel()) then
  193.                     print("Turtle is out of fuel, Powering Down...")
  194.                     return
  195.                 end
  196.                 forward()
  197.                 print(string.format("Row: %d   Col: %d", row, col))
  198.             end
  199.             if(col ~= width) then
  200.                 turnAround(tier)
  201.             end
  202.             manageInventory()
  203.         end
  204.         riseTier()
  205.     end
  206. end
  207.  
  208. start()
  209.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement