Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tunnel Digging Script for CC: Tweaked
- -- Digs a 3x3 tunnel for a specified distance, with auto-refueling.
- -- Function to refuel if needed
- local function refuelIfNeeded()
- if turtle.getFuelLevel() < 10 then
- print("Low fuel! Attempting to refuel...")
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then -- Check if the item can refuel
- turtle.refuel()
- print("Refueled with item in slot " .. i)
- break
- end
- end
- if turtle.getFuelLevel() < 10 then
- print("Out of fuel! Please add fuel to the turtle.")
- while turtle.getFuelLevel() < 10 do
- sleep(1)
- end
- end
- end
- end
- -- Function to dig a 3x3 section
- local function dig3x3()
- -- Dig the bottom row
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- -- Dig middle and upper rows
- for _ = 1, 2 do
- turtle.digUp()
- turtle.up()
- turtle.dig()
- turtle.forward()
- end
- -- Return to the bottom layer
- for _ = 1, 2 do
- turtle.back()
- turtle.down()
- end
- end
- -- Main function to dig the tunnel
- local function digTunnel(length)
- for i = 1, length do
- print("Digging segment " .. i .. " of " .. length)
- refuelIfNeeded()
- dig3x3()
- end
- print("Tunnel completed!")
- end
- -- Get user input for tunnel length
- print("Enter the tunnel length:")
- local length = tonumber(read())
- if length and length > 0 then
- digTunnel(length)
- else
- print("Invalid input! Please enter a positive number.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement