Quite simple, however your code is flawed, and everything is stuck inside your dig function.
A few things.
One, when moving back, you cannot dig there, it digs forward.
Two, it's turtle.back, not turtle.Backward.
Three, it's turtle.forward not turtle.Forward, capitalization matters.
Four, at your function dig, add and extra end at the end of that, and remove ONE end at the bottom of your script.
Five, if you want things to loop, put it inside the loop. rednet.receive stops the loop and waits until it receives a message, then continues. Ex:
while true do
local id,message = rednet.receive()
if message = "Codemeplease" then
print("I like cake, not code, MWAHAHHAHHAHAHAHA")
end
end
Six, attempt to indent your code, if you notice what I've done ^ is that when I hit a loop, function, or if statement, I add two spaces to each line under it, until I meet it's end, then I bring it back two spaces for the next lines.
Seven, you do not need your functions, they're useless actually. Just renaming old functions, and actually making your code slower.
Eight, attempt to use locals, they're a bit tricky, but are faster than globals. Which means that your variables in your script, can be accessed anywhere on the computer until it's shutdown. Locals, cannot.
A little tutorial. Check the variable scope area.
Nine, when posting code onto the forums, try to do what I did, a little easier on the eyes :P/> [.CODE] YOUR CODE HERE [./CODE] Just put this, without the .'s and you will see. Or on the bar above your text, look for the blue
<>, it will pop up a window for you to type your code into, and will do this for you.
That's about it, your immediate problem, was answered on number 4 and 5