-- Get player inputs
print("Enter current Y level:")
local startY = tonumber(read())
print("Enter target Y level:")
local targetY = tonumber(read())
print("Enter staircase height (e.g., 3):")
local stairHeight = tonumber(read())
print("Enter staircase width (e.g., 2):")
local stairWidth = tonumber(read())
-- Validate inputs
if not startY or not targetY or not stairHeight or not stairWidth then
print("Invalid input. Exiting.")
return
end
if targetY >= startY then
print("Target Y level must be lower than current level. Exiting.")
return
end
local steps = startY - targetY
print("Preparing to dig staircase down " .. steps .. " steps, height " .. stairHeight .. ", width " .. stairWidth)
-- Helper: ensure block under is solid
local function ensureFloor()
if not turtle.detectDown() then
for slot = 1, 16 do
local detail = turtle.getItemDetail(slot)
if detail and detail.name ~= "minecraft:torch" then
turtle.select(slot)
turtle.placeDown()
return
end
end
print("Warning: No blocks available to fill air gap under step!")
end
end
-- Helper: dig height
local function digHeight()
for h = 1, stairHeight - 1 do
turtle.digUp()
turtle.up()
end
-- Return to bottom
for h = 1, stairHeight - 1 do
turtle.down()
end
end
-- Helper: dig width
local function digWidth()
for w = 1, stairWidth - 1 do
turtle.turnRight()
turtle.dig()
turtle.forward()
digHeight()
turtle.back()
turtle.turnLeft()
end
end
-- Main loop
for i = 1, steps do
-- Dig front and down
while turtle.detect() do
turtle.dig()
end
-- Dig height
digHeight()
-- Dig width (right side)
digWidth()
-- Move forward
if not turtle.forward() then
print("Blocked! Could not move forward.")
return
end
-- Dig down
while turtle.detectDown() do
turtle.digDown()
end
-- Move down
if not turtle.down() then
print("Blocked! Could not move down.")
return
end
-- Ensure solid floor
ensureFloor()
end
print("Finished digging staircase.")