The reason it is messing up is because direction() calls initial() which calls platform() which calls direction() which calls initial() etc.
There seem to be alot of conditions that aren't needed. for example on line 65:
i=1
while i < 5 and row < 10 do
forward()
i = i+1
if i == 5 and row <= 10 and rijtje == 5 then
line = 1
goDown() -- It is custom to make the first word lowercase, and every word after start with a capital
end
end
the forward function does nothing to the variables, and only i gets changed. Since row and rijtje never reach their variable amounts, it never gets called, unless it reaches it before that point, where it is pointless.
You make rijtje increase in both platform() and initiate()
Just a note, change your forward function to :
local function forward()
while not turtle.forward() do
if turltle.detect() then
turtle.dig()
else
turtle.attack() --you may want to use sleep() instead so that if you get in its way, it doesn't kill you :)/>/>/>
end
end
end
With this it will keep digging until it can move forward, stopping gravel or sand from messing it up.
Another suggestion, instead of having the set variables of 5 and 10, change them to variable, so if you want to change it later, you can change it in just one spot, instead of the whole code.
A question: Why are there some comments that are in english, and others in a language that I am not sure of?