z_count = 0 face = 1 function turn_left() turtle.turnLeft() if face == 0 then face = 1 elseif face == 1 then face = 2 elseif face == 2 then face = 3 elseif face == 3 then face = 0 end end function turn_right() turtle.turnRight() if face == 0 then face = 3 elseif face == 1 then face = 0 elseif face == 2 then face = 1 elseif face == 3 then face = 2 end end function dig_x(width) for i = 0,width, 1 do turtle.digUp() turtle.dig() turtle.forward() end end -- dig and move down one block to start the staircase -- turtle.digDown() -- turtle.down() -- we moved down once, so we increment the z_count -- z_count = z_count + 1 function dig(width) -- face: 1, the starting position if face == 1 then turn_right() turtle.digDown() turtle.down() dig_x(width - 1) -- face: 0, we are faced right from starting position elseif face == 0 then turn_left() turtle.dig() turtle.forward() turn_left() dig_x(width - 1) turn_right() -- dig end end while(true) do dig(4) end