Because of this problem as far as I can see I will have to move the redundancies outside of the coroutine or nest coroutines. Now the issue is having the coroutine report success or failure (or just failure).
Running coroutine.yield(turtle.forward()) returns the incredibly unhelpful turtle_response and running
co = coroutine.create(function()
turtle.forward()
end)
repeat
a = {coroutine.resume(co)}
print(a[2])
until a[2]~= "turtle_response"
is ended due to failing to yield. I would expect it to return something other than turtle_response before failing to yield as it cannot move and therefore turtle.forward() should have stopped.Please note i cannot have the coroutine report success or failure after the move is completed. I am backing up the turtle's displacement immediately to file in case of unexpected shutdown since as far as minecraft is concerned the turtle is in the new location as soon as a successful move begins. If a crash were to occur between starting and ending the movement, which is highly probable, then the actual location and stored locations would be out of sync and that would cause irritation.