stairdig.lua

                Never    
Lua
       
--Functions

function digRow(a)
    for x=1,a,1 do
    turtle.dig()
    turtle.forward()
    l_offset=l_offset+lomod
    end
end

function buildStair()
    turtle.select(1)
    if turtle.detect() then
        turtle.turnRight()
    end
    turtle.place()
    turtle.up()
    turtle.forward()
end

function goHome(dd)
    for d1=1,dd do
        turtle.up()
    end
    for slot=2,16 do
        turtle.select(slot)
        turtle.drop()
    end
    for d1=1,dd do
        turtle.down()
    end
end

--Params

print("Enter length")
l=io.read()
l=l-1

print("Enter width")
w=io.read()


print("Enter depth")
d=io.read()

print("Place blocks in slot 1")
print("Hit any key after that.")
wait=io.read()

--Main
w_offset=0
l_offset=0
womod=-1
lomod=-1

turnDirection=0
for depth=1,d,1 do

womod=womod*-1
lomod=lomod*-1

firstturn=true

turtle.digDown()
turtle.down()

for y=1,w,1 do

if firstturn==false then
if (turnDirection % 2 == 0) then
    turtle.turnRight()
    turtle.dig()
    turtle.forward()
    w_offset=w_offset+womod
    turtle.turnRight()
    lomod=lomod*-1
else
    turtle.turnLeft()
    turtle.dig()
    turtle.forward()
    w_offset=w_offset+womod
    turtle.turnLeft()
    lomod=lomod*-1
end
turnDirection=turnDirection+1

end
firstturn=false
for x=1,l,1 do
digRow(1)
end
end

if (depth % 2 == 0) then
    goHome(depth)
end
turtle.turnLeft()
turtle.turnLeft()

end

for depth=1,d,1 do

select(1)
buildStair(1)

end

print(l_offset)
print(w_offset)