Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define the trash items
- local trashItems = {
- "minecraft:dirt",
- "minecraft:cobblestone",
- "minecraft:diorite"
- }
- -- Function to check if an item is trash
- local function isTrash(item)
- for _, trash in ipairs(trashItems) do
- if item == trash then
- return true
- end
- end
- return false
- end
- -- Function to deposit items into a chest above the turtle
- local function depositItems()
- for slot = 2, 16 do -- Start from slot 2 since slot 1 has the chest
- turtle.select(slot)
- local itemDetail = turtle.getItemDetail()
- if itemDetail then
- if isTrash(itemDetail.name) then
- turtle.dropDown() -- Dispose of trash items
- else
- turtle.dropUp() -- Deposit other items in chest above
- end
- end
- end
- end
- -- Function to check if the inventory is full
- local function isInventoryFull()
- for slot = 2, 16 do -- Check from slot 2 to avoid overriding the chest in slot 1
- if turtle.getItemCount(slot) == 0 then
- return false
- end
- end
- return true
- end
- -- Function to place a chest above the turtle and deposit items
- local function placeChestAndDeposit()
- turtle.select(1)
- if turtle.getItemDetail() and turtle.getItemDetail().name == "minecraft:chest" then
- if turtle.detectUp() then
- turtle.digUp() -- Ensure space is clear for the chest
- end
- turtle.placeUp()
- depositItems()
- else
- print("No chest found in the first slot! Please place a chest in slot 1 and type 'y' to continue.")
- repeat
- local input = read()
- until input == "y"
- end
- end
- -- Function to dig straight down in one column
- local function digColumn(depth)
- for d = 1, depth do
- if isInventoryFull() then
- placeChestAndDeposit()
- end
- -- Dig down and move down
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- -- Avoid bedrock
- local success, data = turtle.inspectDown()
- if success and data.name == "minecraft:bedrock" then
- return false
- end
- end
- return true
- end
- -- Function to return to the top of the column
- local function returnToTop(depth)
- for i = 1, depth do
- turtle.up()
- end
- end
- -- Function to dig a quarry straight down
- local function quarry(width, length, depth)
- local x, z = 0, 0 -- Track position within the quarry
- for l = 1, length do
- for w = 1, width do
- local continue = digColumn(depth)
- if not continue then
- return
- end
- returnToTop(depth)
- -- Move to the next position
- if w < width then
- turtle.dig()
- turtle.forward()
- x = x + 1
- end
- end
- -- Move to the next row
- if l < length then
- if l % 2 == 1 then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- z = z + 1
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- z = z + 1
- end
- end
- end
- end
- -- Function to check if a chest is in the first slot before starting
- local function checkChest()
- turtle.select(1)
- if not turtle.getItemDetail() or turtle.getItemDetail().name ~= "minecraft:chest" then
- print("No chest found in the first slot! Please place a chest in slot 1 and type 'y' to start.")
- repeat
- local input = read()
- until input == "y"
- end
- end
- -- Get quarry dimensions from the user
- print("Enter quarry width:")
- local width = tonumber(read())
- print("Enter quarry length:")
- local length = tonumber(read())
- print("Enter quarry depth:")
- local depth = tonumber(read())
- -- Check for chest in the first slot
- checkChest()
- -- Run the quarry function with user-provided dimensions
- quarry(width, length, depth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement