Advertisement
TheSkyPaster

ComputerCraft 1.5 Quarry Digger

Jan 24th, 2020 (edited)
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local bedrockFound = false
  2.  
  3. local function goUp()
  4.     local upFound = false
  5.  
  6.     while not upFound do
  7.         if not turtle.moveUp() then
  8.             upFound = true
  9.         end
  10.     end
  11. end
  12.  
  13. local function checkInventorySpace()
  14.     local isEmptySlot = false
  15.     for i = 1, 16 do
  16.         if turtle.getItemCount(i) <= 0 then
  17.             isEmptySlot = true
  18.             --break() TurtleOS 1.5 doesnt have?
  19.         end
  20.     end
  21.     return isEmptySlot
  22. end
  23.  
  24. local function emptyInventory()
  25.     for i = 2, 16 do --empty every slot except first one (for fuel)
  26.         turtle.select(i)
  27.         turtle.dropUp()
  28.     end
  29.     turtle.select(1)
  30. end
  31.  
  32. while not bedrockFound do
  33.     turtle.select(1) --select slot 1 for fuel
  34.     if turtle.getFuelLevel() <= 5 then
  35.         turtle.refuel()
  36.     end
  37.    
  38.     if checkInventorySpace() then --if has space in inventory do dig
  39.    
  40.         if turtle.detectDown() then
  41.             local brokeBlock = turtle.digDown()
  42.            
  43.             if not brokeBlock then --block is unbreakable
  44.                 bedrockFound = true
  45.             end
  46.             turtle.moveDown()
  47.         end
  48.     else
  49.         goUp()
  50.         emptyInventory()
  51.     end
  52. end
  53.  
  54. if bedrockFound then
  55.     goUp()
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement