Had a bit of fun doin some spiral patterns.
I am going to use this in a future tree felling program.
Todo: make it -size safe moving inward for excavation programs.
Todo: Check for fuel before starting (math.abs(size)*math.abs(size)+math.ceil(size/2)*2)
Todo-maybe: keep coordinate system updated | limit movement outside of specified coords

local function turnL() turtle.turnLeft()  end
local function turnR() turtle.turnRight() end
local function fward()
 while not turtle.forward() do
 -- insert check for fuel
 -- insert attack/dig
 end
end
function outwardSpiral(size)
 for frence=1,size do
  for sector=1,2 do
   for arc=1,frence do
    fn() -- goes before moving to catch corner cases correctly(tm).
    fward()
    --print(""..a.." "..b.." "..c)
   end
   turnL()
  end
 end
 --return home
 home=math.ceil(size/2)
 for a=1,home do fward() end
 turnL()
 for a=1,home do fward() end
 if math.fmod(size,2) == 0 then turnL()
 else turnR()
 end
end

-------testcode-------
local fn()
 --put your code here
 --turtle.dig()
 --turtle.digUp()
 --turtle.digDown()
end
outwardSpiral(7)

Edit: Fix some spaces that were rm by the bbcode code inserter.