Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define the ores to search for
- local targetOres = {
- ["minecraft:iron_ore"] = true,
- ["minecraft:lead_ore"] = true,
- ["minecraft:nickel_ore"] = true
- }
- -- Function to detect the block in front of the turtle
- local function detectBlock()
- local success, data = turtle.inspect()
- if success and targetOres[data.name] then
- return true
- end
- return false
- end
- -- Function to detect the block above the turtle
- local function detectBlockUp()
- local success, data = turtle.inspectUp()
- if success and targetOres[data.name] then
- return true
- end
- return false
- end
- -- Function to detect the block below the turtle
- local function detectBlockDown()
- local success, data = turtle.inspectDown()
- if success and targetOres[data.name] then
- return true
- end
- return false
- end
- -- Function to mine in front of the turtle
- local function mineForward()
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- -- Function to mine up
- local function mineUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.up()
- end
- -- Function to mine down
- local function mineDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- turtle.down()
- end
- -- Function to mine around the turtle (front, left, right, up, down)
- local function mineAround()
- -- Check front
- if detectBlock() then
- mineForward()
- mineAround()
- turtle.back()
- end
- -- Check left
- turtle.turnLeft()
- if detectBlock() then
- mineForward()
- mineAround()
- turtle.back()
- end
- turtle.turnRight()
- -- Check right
- turtle.turnRight()
- if detectBlock() then
- mineForward()
- mineAround()
- turtle.back()
- end
- turtle.turnLeft()
- -- Check up
- if detectBlockUp() then
- mineUp()
- mineAround()
- turtle.down()
- end
- -- Check down
- if detectBlockDown() then
- mineDown()
- mineAround()
- turtle.up()
- end
- end
- -- Main mining function
- local function mineTunnel(length)
- for i = 1, length do
- mineForward()
- mineAround()
- end
- end
- -- Main program
- print("Starting mining program...")
- local tunnelLength = 20 -- Adjust as needed
- mineTunnel(tunnelLength)
- print("Mining program completed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement