Advertisement
ApparentlyChimp

Quarry

Jun 4th, 2023 (edited)
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 KB | None | 0 0
  1. local function askDimensions()
  2.     print("length:")
  3.     Length = tonumber(read())
  4.  
  5.     print("width:")
  6.     Width = tonumber(read())
  7.  
  8.     print("height:")
  9.     Height = tonumber(read())
  10. end
  11.  
  12. local function fuel()
  13.     turtle.select(15)
  14.  
  15.     if turtle.getItemDetail then
  16.         local item = turtle.getItemDetail()
  17.  
  18.         while true do
  19.             if item ~= nil and item.name == "minecraft:coal" or item.name == "minecraft:coal_block" then
  20.                 turtle.refuel()
  21.                 break
  22.             else
  23.                 print("no coal or coal blocks in second to last slot!")
  24.                 sleep(5)
  25.             end
  26.         end
  27.     else
  28.         print("no coal or coal blocks in second to last slot!")
  29.         sleep(5)
  30.     end
  31. end
  32.  
  33. local function checkFuel()
  34.     while turtle.getFuelLevel() < Length * Height * Width * 5 do
  35.         print("not enough fuel")
  36.         sleep(2)
  37.         fuel()
  38.     end
  39. end
  40.  
  41. local function checkForChests()
  42.     -- checking if the turtle has a chest in the last slot
  43.     turtle.select(16)
  44.     while true do
  45.         if turtle.getItemDetail() then
  46.             local item = turtle.getItemDetail()
  47.  
  48.             while item.name ~= "minecraft:chest" or item.count < 64 do
  49.                 print("vanilla chest needed in last slot!")
  50.                 sleep(5)
  51.             end
  52.  
  53.             break
  54.         else
  55.             print("vanilla chest needed in last slot!")
  56.             sleep(5)
  57.         end
  58.     end
  59. end
  60.  
  61. local function initialize()
  62.     askDimensions()
  63.  
  64.     checkFuel()
  65.  
  66.     checkForChests()
  67. end
  68.  
  69. local function chestDump()
  70.     -- chest must be placed in 16th slot
  71.     turtle.select(16)
  72.     turtle.placeDown()
  73.  
  74.  
  75.     for i = 1, 15, 1 do
  76.         turtle.select(i)
  77.         turtle.dropDown()
  78.     end
  79. end
  80.  
  81. local function checkForInventorySpace()
  82.     local dumpNeeded = true
  83.  
  84.     for i = 1, 15, 1 do
  85.         if dumpNeeded == false then
  86.             break
  87.         end
  88.  
  89.         turtle.select(i)
  90.  
  91.         if (turtle.getItemDetail()) then
  92.             dumpNeeded = false
  93.         end
  94.     end
  95.  
  96.     if dumpNeeded then
  97.         chestDump()
  98.     end
  99. end
  100.  
  101. local function digLayer()
  102.     -- mine the whole area
  103.     for z = 0, Width, 1 do
  104.         for x = 0, Length, 1 do
  105.             print("mining layer")
  106.         end
  107.     end
  108. end
  109.  
  110. local function moveDownLayer()
  111.     -- check block below, if not air, water or lava mine, move down
  112.     print("going down one layer")
  113. end
  114.  
  115. local function dig()
  116.     for layer = 0, Height, 1 do
  117.         digLayer()
  118.  
  119.         if layer < Height - 1 then
  120.             moveDownLayer()
  121.         end
  122.     end
  123. end
  124.  
  125. local function main()
  126.     initialize()
  127.     dig()
  128.  
  129.     print("done")
  130. end
  131.  
  132. main()
  133.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement