Used for simple handling of the turtle from the command-line.
My first LUA script and i ended up using it a lot - Bad coding but it works :)/>
I have made some nifty little batch files where i am using R via the shell command! None published though, just mentioning as inspiration.

SYNTAX: <Program name> <Orders> [Run this program after completion]

Example 1:
r fffurrfffdll
This orders the turtle to go forward 3, up 1, turning right 2 times, forward 3,
down 1, turning left 2 times. - If anything is blocking the path it will stop
with an error message.

Example 2:
r Bffrff3y
This orders the turtle to move 2 forward, turn right, move 2 forward and finally place a block from slot #3 below the turtle.
NOTE: Since the orders starts with a "B" then it will dig blocks if any is present in its path

The code:
Spoiler

local version=1
-- aDY5Ez8M
-- r
-- sEi'2014-2016
--[[
	R macros WIP by sEi'2014-2016 - (C)opyleft (Do what you want with the script)
	Get this script here: http://pastebin.com/aDY5Ez8M
	
	Used for simple handling of the turtle from the command-line.
	
	My first script and i ended up using it a lot - Bad coding but it works :)/>/>/>/>
	
	Name the script whatever you want, i name it "r" so its quick and easy to use!
	
	Place this file in the root of the turtle directory and use like this example

	SYNTAX: <Program name> <Orders> [Run this program after completion]

	(If you renamed the script use that name instead of the first r)
	Example 1:
	r fffurrfffdll
	This orders the turtle to go forward 3, up 1, turning right 2 times, forward 3,
	down 1, turning left 2 times. - If anything is blocking the path it will stop
	with an error message. (Use "I" if errors should be ignored - NOTE: Will give unpredictable
	results!)

	Example 2:
	r Bffrff
	This orders the turtle to move 2 forward, turn right and move 2 forward.
	NOTE: Since the orders starts with a "B" then it will dig blocks if any is present in its path
	
	I have made some nifty little batch files where i am using R via the shell command!
	None published though, just mentioning as inspiration.

	RESERVED COMMANDS:
	/help = Prints the reserved commands
	b = Set BREAK = false (default) - Turtle is NOT breaking blocks that is in his way.
	B = Set BREAK = True - Turtle is breaking (digging) blocks that are in the way for his move.
	P = Place a block in front of turtle from selected slot (default=1).
		If BREAK = False - If the spot is not empty then the turtle stops with an error message .
		If BREAK = True - If the spot is not empty then the turtle Digs until spot is empty and
		then place a block.
	l = Turn Left 1.
	r = Turn Right 1.
	f = Go forward 1.
	F = Go Forward UNTIL path is blocked. (BREAK true/false have no effect!)
	u = Go Up 1.
	U = Go Up UNTIL path is blocked. Use with CAUTION ;)/>/>/>/> (BREAK true/false have no effect!)
	d = Go Down 1.
	D = Go Down UNTIL path is blocked. (BREAK true/false have no effect!)
	x = Go Back 1.
	X = Go Back UNTIL path is blocked. (BREAK true/false have no effect!)
	y = Place block Down
	Y = Place block Up
	i = Dig in front of Turtle. (BREAK true/false have no effect!)
	z = Dig Down 1 time (BREAK true/false have no effect!)
	Z = Dig Up 1 time (BREAK true/false have no effect!)
	w = Do NOT warn when only 1 in current slot
	W = (default) Warn when only 1 in current slot
	0 (zero) = Use any slot
	1-9,10,11,12,13,14,15,16 = Slot selection
	I = Ignore blocked path (NOTE: Will give unpredictable results!)
]]--
-- INIT
local sCommands = "bBlrPfFuUdDxXyYizZ123456789wW"
local tArgs={...}
local sProg = tArgs[1] or "/help"
local sArg2 =tArgs[2] or ""
local iDefSlot = 0
iCurSlot = 1 --iDefSlot
local bBreak = false
local bError = false
local bIgnore = false
local oT=turtle
local max=#sProg
local sBak=""
local sOrder
local iWarn=1
local iEmpty1=4
--local iEmpty2
-- FUNCTIONS
local function doThis(sChar,sLastMsg)
	--doFuel()
	if bError==false then
		--crude checks
		if tonumber(sChar) ~= nil then --is number then is slotselect
			local iChar=tonumber(sChar)
			if iChar==0 then
				local iTemp=0
				while iTemp==0 do
					iTemp = findAny()
					if iTemp>0 then
						oT.select(iTemp)
					else
						--print("No more materials (ANY)")
						print("--ERROR--\nNo more materials (ANY)\nI choose to Pause\n--END--")
						print("Fill any slot and press ENTER\nor press and hold CTRL-T to quit")
						doWaitForEnter()
					end
				end
			else
				iCurSlot=iChar
				oT.select(iCurSlot)
			end
		end
		if sChar=="I" then bIgnore=true end
		if oT.detect() and sChar=="P" then --Something in the front and we wanna put there
			if bBreak then
				while oT.detect() do
					oT.dig()
					sleep(1)
				end
				myPlace("front")
			else
				if bIgnore==false then
					error("--ERROR--\nBlock in front of me\nI choose to Exit\n--END--")
				end
			end
		elseif sChar=="P" then
			myPlace("front")
		end
		if sChar=="w" then
			iWarn=0
		elseif sChar=="W" then
			iWarn=1
		elseif sChar=="i"then
			oT.dig()
		elseif sChar=="z"then
			oT.digDown()
		elseif sChar=="Z"then
			oT.digUp()
		elseif sChar=="Y" then
			if oT.detectUp() then
				if bBreak then
					while oT.detectUp() do
						oT.digUp()
					end
					myPlace("up")
				else
					if bIgnore==false then
						error("--ERROR--\nBlock over me\nI choose to Exit\n--END--")
						--bError=true
					end
				end
			else
				myPlace("up")
			end
		elseif sChar=="y" then
			if oT.detectDown() then
				if bBreak then
					while oT.detectDown() do
						oT.digDown()
					end
					myPlace("down")
				else
					if bIgnore==false then
						error("--ERROR--\nBlock under me\nI choose to Exit\n--END--")
						--bError=true
					end
				end
			else
				myPlace("down")
			end
		elseif sChar == "U" then
			while oT.detectUp() == false do
				doFuel()
				oT.up()
			end
		elseif sChar == "D" then
			while oT.detectDown() == false do
				doFuel()
				oT.down()
			end
		elseif sChar == "F" then
			while oT.detect() == false do
				doFuel()
				oT.forward()
			end
		elseif sChar=="x"then
			oT.turnRight()
			oT.turnRight()
			walk()
			oT.turnRight()
			oT.turnRight()
		elseif sChar=="X" then
			oT.turnRight()
			oT.turnRight()
			while oT.detect() == false do
				doFuel()
				oT.forward()
			end
			oT.turnRight()
			oT.turnRight()
		elseif sChar=="b" then
			bBreak = false
		elseif sChar=="B" then
			bBreak = true
		elseif sChar=="f" then
			walk()
		elseif sChar=="l" then
			oT.turnLeft()
		elseif sChar=="r" then
			oT.turnRight()
		elseif sChar=="u" then
			if oT.detectUp() then
				if bBreak then
					while oT.detectUp() do
						oT.digUp()
						sleep(1)
					end
				else
					if bIgnore==false then
						error("--ERROR--\nBlock over me\nI choose to Exit\n--END--")
						--bError=true
					end
				end
			end
			doFuel()
			oT.up()
		elseif sChar=="d" then
			if oT.detectDown() then
				if bBreak then
					while oT.detectDown() do
						oT.digDown()
						sleep(1)
					end
				else
					if bIgnore==false then
						error("--ERROR--\nBlock under me\nI choose to Exit\n--END--")
						--bError=true
					end
				end
			end
			doFuel()
			oT.down()
		end
	end
end

function doFuel()
	while turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 do
		for i = 16, 1,-1 do -- loop through the slots
		  turtle.select(i) -- change to the slot
		  if turtle.refuel(0) then -- if it's valid fuel
				local halfStack = math.ceil(turtle.getItemCount(i)/2) -- work out half of the amount of fuel in the slot
				turtle.refuel(halfStack) -- consume half the stack as fuel
				break
		  end
		end
		turtle.select(iCurSlot)
		if turtle.getFuelLevel() < 1 then
			print("OUT OF FUEL - Put some fuel in a slot and press ENTER")
			doWaitForEnter()
		end
	end
end

function myPlace(sDir)
	if iCurSlot>0 then
		oT.select(iCurSlot)
	else
		local iTemp=0
		while iTemp==0 do
			iTemp = findAny()
			if iTemp>0 then
				oT.select(iTemp)
				iCurSlot=iTemp
			else
				--print("No more materials (ANY)")
				print("--ERROR--\nNo more materials (ANY)\nI choose to Pause\n--END--")
				print("Fill any slot and press ENTER\nor press and hold CTRL-T to quit")
				doWaitForEnter()
			end
		end
	end
	if oT.getItemCount(iCurSlot)==1 then
		local iT
		--fyld up if any around
		for iT=1,16 do
			if iT~=iCurSlot then
				if oT.compareTo(iT) then
					local iTemp2=64-oT.getItemCount(iCurSlot)
					oT.select(iT)
					--local iTemp=oT.getItemCount(iCurSlot)
					--if iTemp2<=iTemp then
					--	iTemp=iTemp2
					--end
					oT.transferTo(iCurSlot,iTemp2)
					sleep(1)
					oT.select(iCurSlot)
					break
				end
			end
		end
	end
	if iEmpty1 and (iCurSlot ~= iEmpty1)then
		while oT.getItemCount(iCurSlot)==iWarn do
			print("--ERROR--\nNo more materials in slot: "..iCurSlot.."\nI choose to Pause\n--END--")
			print("Fill slot: "..iCurSlot.." and press ENTER\nor press and hold CTRL-T to quit")
			doWaitForEnter()
		end
	end
	if sDir=="front" then
		oT.place()
	elseif sDir=="up" then
		oT.placeUp()
	elseif sDir=="down" then
		oT.placeDown()
	else --error
		error("ERROR: No such direction: "..sDir.."\nI choose to END\n--END--")
		--bError=true
		return
	end
	
end

function walk()
	if oT.detect() and bBreak then
		while oT.detect() do
			oT.dig()
			sleep(1)
		end
		doFuel()
		oT.forward()
	elseif oT.detect() then
		if bIgnore==false then
			error("--ERROR--\nBlock in front of me\nI choose to Exit\n--END--")
			--bError=true
		end
	else
		doFuel()
		oT.forward()
	end
end

function findAny() --Find a slot containing anything
	local iT
	for iT=1,15 do
		if oT.getItemCount(iT) >0 then return iT end
	end
	return 0
end

function doWaitForEnter()
  while true do
	--Pull the event
	local _, key = os.pullEvent("key")

	if key == keys.enter then
	  break
	end
  end
end
--INIT BOT
--oT.select(iDefSlot)

-- MAIN
if sProg=="/help" then
	print("For help type: r /help")
	print("Reserved commands: "..sCommands)
else
	while false do -- ass tests (true/false)
		local sTemp=tArgs[2]
		if tArgs[2] then
			print("Found Number: "..sProg)
		else
			print("Found NO 2'nd argument")
		end
		return
	end
	print("Running this: "..sProg)
	local iT
	for iT=1,max do
		sOrder=string.sub(sProg,iT,iT)
		doThis(sOrder,sBak)
		sBak=sOrder
	end

--	if bError==true then
--		print("There was error(s)\nPress any key to exit")
--		os.pullEvent("key")
--	end
	if #sArg2>0 then
		doShell(sArg2)
	end
end

https://pastebin.com/aDY5Ez8M I suggest to save the program as "r" for easy use

pastebin get aDY5Ez8M r

My very first script when i started with CC (and LUA), but i have ended up using it very much and as mentioned also made several batch files where i use the "r" program via shell thingy.

Any feedback is very much appreciated.

/sEi