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 the chest
- local function depositItems()
- for slot = 1, 16 do
- turtle.select(slot)
- local itemDetail = turtle.getItemDetail()
- if itemDetail then
- if isTrash(itemDetail.name) then
- turtle.dropDown() -- Dispose of trash items
- else
- turtle.drop() -- Deposit other items in chest
- end
- end
- end
- end
- -- Function to check if the inventory is full
- local function isInventoryFull()
- for slot = 1, 16 do
- if turtle.getItemCount(slot) == 0 then
- return false
- end
- end
- return true
- end
- -- Function to return to starting point (assumed as 0,0,0) and deposit items
- local function returnToStartAndDeposit(x, y, z, direction)
- -- Return to the chest
- turtle.up(y)
- turtle.turnRight(direction)
- turtle.forward(x)
- turtle.turnRight()
- turtle.forward(z)
- -- Deposit items
- depositItems()
- -- Return to the mining position
- turtle.back(z)
- turtle.turnLeft()
- turtle.forward(x)
- turtle.turnLeft(direction)
- turtle.down(y)
- end
- -- Function to dig straight down in one column
- local function digColumn(depth)
- for d = 1, depth do
- -- Check if inventory is full
- if isInventoryFull() then
- return true
- 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)
- 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()
- end
- end
- -- Move to the next row
- if l < length then
- if l % 2 == 1 then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- end
- -- Return to the chest and deposit final items
- returnToStartAndDeposit(0, 0, 0, 0)
- 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())
- -- Run the quarry function with user-provided dimensions
- quarry(width, length, depth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement