I've been working on this program for a few days and I've burned my self out on trying to find some bugs that are anyoing the heck out of me. The two that I know
of are when breaking block if the turtle comes next to a air "block" it stops moving until I place something in that spot. The other bug is with doing slices they don't
stay even. As in the first one is the same height but the next slice is one block lower and it altenerats between the two. Any fresh eyes to see what's wrong would
be great.

~ Vitez

Spoiler
term.clear()
term.setCursorPos(1,1)

-- VertShaft

-- variables
	local x,y,z
	local dirction = 0 -- 0 = front, 1 == left, 2 == right, 3 == back
	local fuelEnabled = false
	local torchSlot = 9
	local fuelSlot = 16
	-- origin
	local xo = 0
	local yo = 0
	local yo = 0
	-- current
	local xc = 0
	local yc = 0
	local zc = 0
	-- save
	local xs = 0
	local ys = 0
	local zs = 0
	
-- functions

-- Not used since tekkit doesn't have the latest CC version
local function checkFuel()
end

local function setup()
	print("Welcome to Shaft!")
	print()
	print("Waring: this program assumes that miner is starting on the left of the shaft!")
	print("All values are positive integers.")
	write("Torches in slot ")
	write(torchSlot)
	if fuelEnabled == true then
		write(" and Fuel in slot ")
		print(fuelSlot , ".")
	else
		print(". ")
	end
	write("Width: ")
	x = io.read()
	x = tonumber(x)
	--print()
	write("Height: ")
	z = io.read()
	z = tonumber(z) - 1
	--print()
	write("Length: ")
	y = io.read()
	y = tonumber(y)
	print()
	write("Press any key to run.")
	os.pullEvent("key")
end

local function face (dirct)
	rand = math.random(2)
	
	if dirct == 0 then	 -- front
	
		if dirction == 1 then
			turtle.turnRight()
			dirction = 0
		elseif dirction == 2 then
			turtle.turnLeft()
			dirction = 0
		elseif dirction == 3 then
			if rand == 1 then
				turtle.turnRight()
				turtle.turnRight()
			else
				turtle.turnLeft()
				turtle.turnLeft()
			end
			dirction = 0
		elseif dirction == 0 then
			dirction = 0
		end
	
	elseif dirct == 1 then -- left
	
		if dirction == 1 then
			dirction = 1
		elseif dirction == 2 then
			if rand == 1 then
				turtle.turnRight()
				turtle.turnRight()
			else
				turtle.turnLeft()
				turtle.turnLeft()
			end
			dirction = 1
		elseif dirction == 3 then
			turtle.turnRight()
			dirction = 1
		elseif dirction == 0 then
			turtle.turnLeft()
		end
		
	elseif dirct == 2 then -- right
	
		if dirction == 1 then
			if rand == 1 then
				turtle.turnRight()
				turtle.turnRight()
			else
				turtle.turnLeft()
				turtle.turnLeft()
			end
			dirction = 2
		elseif dirction == 2 then
			dirction = 2
		elseif dirction == 3 then
			turtle.turnRight()
			dirction = 2
		elseif dirction == 0 then
			turtle.turnRight()
			dirction = 2
		end
		
	elseif dirct == 3 then -- back
	
		if dirction == 1 then
			turtle.turnLeft()
			dirction = 3
		elseif dirction == 2 then
			turtle.turnLeft()
			dirction = 3
		elseif dirction == 3 then
			dirction = 3
		elseif dirction == 0 then
			if rand == 1 then
				turtle.turnRight()
				turtle.turnRight()
			else
				turtle.turnLeft()
				turtle.turnLeft()
			end
			dirction = 3
		end
	end
end

local function moveForword()

	face(0)
	
	repeat
		if turtle.detect() then
			turtle.dig()
		else
		end
	until turtle.forward()
	
	yc = yc + 1
end

local function moveBackword()
	
	face(3)
	
	repeat
		if turtle.detect() then
			turtle.dig()
		else
		end
	until turtle.forward()
	
	yc = yc - 1
end

local function moveLeft()
	
	face(1)
	
	repeat
		if turtle.detect() then
			turtle.dig()
		else
		end
	until turtle.forward()
	
	xc = xc - 1
end
	
local function moveRight()
	
	face(2)
	
	repeat
		if turtle.detect() then
			turtle.dig()
		else
		end
	until turtle.forward()

	xc = xc + 1
end

local function moveUp()

	repeat
		if turtle.detect() then
			turtle.digUp()
		else
		end
	until turtle.up()
	zc = zc + 1
end

local function moveDown()
	
	repeat
		if turtle.detect() then
			turtle.digDown()
		else
		end
	until turtle.down()
	zc = zc - 1
end

local function checkStorage()
	if turtle.getItemCount(torchSlot-1) >= 1 then -- the slot before where the torches are stored at should be the last slot for internal storage.
		returnStorage()
	end
end

local function torch()

end

local function returnStorage()
	for i = 1,torchSlot do
		
			turtle.select(i)
			turtle.drop()
	end
	returnMine()
end

local function returnBase()
	
	xs = xc
	ys = yc
	zs = zc
	
	if zc ~= 0 then
		for i = 1, zc, 1 do
			moveDown()
		end
	end
	
	if xc ~= 0 then
		for i = 1, xc, 1 do
			moveLeft()
		end
	end
	
	if yc ~= 0 then
		for i = 1, yc, 1 do
			moveBackword()
		end
	end
end

local function returnMine()

	for index = 1, ys, 1 do
		moveForword()
	end

	for index = 1, xs, 1 do
		moveRight()
	end
	
	for index = 1, zs, 1 do
		moveUp()
	end
end

local boolSwitch = true

local function slice()

	for index = 1, x, 1 do
		if boolSwitch then
			for i = 1, z, 1 do
				moveUp()
			end
			boolSwitch = not boolSwitch
		else
			for i = 1, z, 1 do
			moveDown()
			end
			boolSwitch = not boolSwitch
		end
		if(index ~= x) then
			moveRight()
		end
	end
	checkStorage()
end

local function resetX()
	if xc ~= 0 then
		for i = 1, xc, 1 do
			moveLeft()
		end
	end
end

local function shaft()
	for index = 1, y, 1 do
		moveForword()
		slice()
		resetX()
		boolSwitch = not boolSwitch
	end
end

local function main()
	setup()
	print()
	print("Running...")
	shaft()
	returnBase()
	face(0)
	print("Done")
end

main()