This program is designed to mine in a spiral around a center drop-off chest. It takes a height, radius(space between chest and wall you want to start on), and optional maximum radius. If no max radius is set, it uses 32, as that will always be within a chunk loader of 3x3 chunks placed under the chest.
Slot 16 never gets unloaded, so it is recommended to put the fuel there, and coal coke is recommended if planning to let it mine any serious sized area.
I wrote this with the goal of setting the turtle on Y=11, and mining with height 5(up to Y=16), to collect as many valuables without the excess of cobble. This is the only scenario in which this program has been tested.

Edit: added torch placement, places a torch every 4 blocks, in the ground. A non-solid floor may interfer with this.

Code:
Spoiler– Program to mine in a spiral.
– Starts by going forward as far as it can, then to the left as far as it can.
– From here, it mines clockwise, with the supplied height measured from the
– starting point of the turtle moving up.
– Place fuel in slot 16, coal coke is recommended for large quarries.
– Turtle will refuel from any fuel in inventory, allowing slot 16 fuel to last
– longer if coal is mined. Function refuel() can be edited to only refuel
– from slot 16.
– Place torches in slot 15 to light the area.

– Created September 19th, 2012
– By Starxplor
– Last Updated On September 27th, 2012
– Version 1.41-1.4 (CC version dash spiralMine version)

tArgs = { … }

if #tArgs < 1 or #tArgs > 3 then
print( "Usage: spiralMine <height> <radius> <optional max radius>" )
return
end

height = tonumber( tArgs[1] )
radius = tonumber(tArgs[2])
if (#tArgs > 2) then
maxRad = tonumber(tArgs[3])
else
maxRad = 32
end

if (height < 1 or radius < 1) then
print( "I'm sorry, Dave. I'm afraid I can't do that." )
return
end

print("Mining " .. height .. " high and starting with radius of " .. radius)

atX = 0
atY = 0
atZ = 0
unloaded = 0

– refueling function, returns false if it needed to refuel and failed to.
function refuel()
local fuelLevel = turtle.getFuelLevel()
refueled = false
if fuelLevel == "unlimited" or fuelLevel > 0 then
refueled = true
end
if not refueled then
for n=1,16 do
if turtle.getItemCount(n) > 0 then
turtle.select(n)
if turtle.refuel(1) then
turtle.select(1)
refueled = true
end
end
end
end
turtle.select(1)
– if (refueled) then
– print("refueled: true")
– else
– print("refueled: false")
– end
return refueled
end

function tryDigDown()
while turtle.detectDown() do
if turtle.digDown() then
–collect()
sleep(0.5)
else
return false
end
end
return true
end

function tryDigUp()
while turtle.detectUp() do
if turtle.digUp() then
–collect()
sleep(0.5)
else
return false
end
end
return true
end

function tryDig()
while turtle.detect() do
if turtle.dig() then
–collect()
sleep(0.5)
else
return false
end
end
return true
end

function advance( direction )
– print("Refueling…")
if not refuel() then
print( "Error, out of fuel at position: " .. atX .. ", " .. atZ)
working = false
end
– print("Trying to move forward…")
while not turtle.forward() do
if turtle.detect() then
if not tryDig() then
return false
end
elseif turtle.attack() then
–collect()
else
sleep( 0.5 )
end
end
if direction == "x" then
atX = atX + 1
elseif direction == "-x" then
atX = atX - 1
elseif direction == "z" then
atZ = atZ + 1
elseif direction == "-z" then
atZ = atZ - 1
end
checkPlaceTorch()
end

function moveUp()
if not refuel() then
print( "Error, out of fuel." )
working = false
end
while not turtle.up() do
if turtle.detectUp() then
if not tryDigUp() then
return false
end
elseif turtle.attackUp() then
–collect()
else
sleep( 0.5 )
end
end
atY = atY + 1
end

function moveDown()
if not refuel() then
print( "Error, out of fuel." )
working = false
end
while not turtle.down() do
if turtle.detectDown() then
if not tryDigDown() then
return false
end
elseif turtle.attackDown() then
–collect()
else
sleep( 0.5 )
end
end
atY = atY - 1
end

function harvestWall(direction)
for i=1, ((radius * 2) + 2) do
advance(direction)
for j=1, height do
moveUp()
end
for j=1, height do
moveDown()
end
end
end

function harvestWall_v2(direction)
for i=1, (radius + 1) do
advance(direction)
for j=1, height do
moveUp()
end
advance(direction)
for j=1, height do
moveDown()
end
checkPlaceTorch() – check to place when back on the ground
end
end

function unload()
for n=1,14 do
unloaded = unloaded + turtle.getItemCount(n)
turtle.select(n)
turtle.dropDown()
end
collected = 0
turtle.select(1)
end

function dropOffLoot(direction)
cornerX = atX
cornerZ = atZ

turtle.turnLeft()
turtle.turnLeft()

–print("Position: " .. atX .. ", " .. atZ)
if direction == "x" then
while atX ~= 0 do
advance("-x")
end
turtle.turnLeft()
while atZ ~= 0 do
advance("z")
end
unload()
turtle.turnLeft()
turtle.turnLeft()
while atZ ~= cornerZ do
advance("-z")
end
turtle.turnRight()
while atX ~= cornerX do
advance("x")
end
elseif direction == "-x" then
while atX ~= 0 do
advance("x")
end
turtle.turnLeft()
while atZ ~= 0 do
advance("-z")
end
unload()
turtle.turnLeft()
turtle.turnLeft()
while atZ ~= cornerZ do
advance("z")
end
turtle.turnRight()
while atX ~= cornerX do
advance("-x")
end
elseif direction == "z" then
while atZ ~= 0 do
advance("-z")
end
turtle.turnLeft()
while atX ~= 0 do
advance("-x")
end
unload()
turtle.turnLeft()
turtle.turnLeft()
while atX ~= cornerX do
advance("x")
end
turtle.turnRight()
while atZ ~= cornerZ do
advance("z")
end
elseif direction == "-z" then
while atZ ~= 0 do
advance("z")
end
turtle.turnLeft()
while atX ~= 0 do
advance("x")
end
unload()
turtle.turnLeft()
turtle.turnLeft()
while atX ~= cornerX do
advance("-x")
end
turtle.turnRight()
while atZ ~= cornerZ do
advance("-z")
end
end
end

function checkPlaceTorch()
if (((math.abs(atX) % 5) == 2) and ((math.abs(atZ) % 5) == 2) and (atY == 0)) then
print("Placing torch at position: " .. atX .. ", " .. atZ)
moveDown() – lazyness makes it easier
moveUp() – to move than just dig
turtle.select(15)
turtle.placeDown()
turtle.select(1)
end
end

print("Getting into position…")

if (radius > 0) then
for i=1, radius do
advance("x")
end
turtle.turnLeft()
for i=1, radius do
advance("-z")
end
turtle.turnRight()
end

– move into corner
print("Adjusting to corner…")
advance("x")
turtle.turnLeft()
advance("-z")
turtle.turnRight()
print("Position: " .. atX .. ", " .. atZ)

working = true
while working do
print("Harvesting first wall…")
– turn and harvest wall, return to center to drop off loot
turtle.turnRight()
harvestWall_v2("z")
dropOffLoot("z")

print("Harvesting second wall…")
– turn and harvest wall, return to center to drop off loot
turtle.turnRight()
harvestWall_v2("-x")
dropOffLoot("-x")

print("Harvesting third wall…")
– turn and harvest wall, return to center to drop off loot
turtle.turnRight()
harvestWall_v2("-z")
dropOffLoot("-z")

print("Harvesting fourth wall…")
– turn and harvest wall, return to center to drop off loot
turtle.turnRight()
harvestWall_v2("x")
dropOffLoot("x")

print("Done with radius " .. radius)
radius = radius + 1
if (radius > maxRad) then
print("Reached maximum radius.")
return
else
print("Adjusting to next corner…")
end
– move to next radius corner
advance("x")
turtle.turnLeft()
advance("-z")
turtle.turnRight()

end

It can also be viewed at http://lug.mtu.edu/pastebin/508

TODO:
- Add ability to restock if matching fuel is in the chest
- Use rednet to display stats/state on a monitor in base, including if it failed to unload all items(chest full)
- Probably other things as well, suggestions accepted, though not always acted on.