And it is basically wrapping the turtle funcitons in new functions to check if they are allowed to move or dig there.
local function checkIfMoved(move,fm,ym) if isInBounds(fm,ym) then local stime = oc() local o,r,r2=pc(move) if not o then print("reached") ost(2) repeat cy("timer") until oc()-stime >= 2 end local o2,fl = pc(gfl) if not o2 then checkGps(true) end if fl < lfl then x=x+fx*fm y=y+ym z=z+fz*fm lfl = fl end if o then return r,r2 else error(r,0) end end sleep(0.2) return false,"Can not move out of the plot" end function turtle.back() return checkIfMoved(bk,-1,0) end function turtle.forward() return checkIfMoved(fd,1,0) endFull Code here
And that does work well unless the current thread calling that function does never return...
coroutine.wrap(turtle.forward)()
If called like this, the upper code does never return from the pcall (pc) in the fourth line, but the turtle does move forward. print("reached") is not executed here and coordinates are not updated
Is there a better way than overwriting coroutine.yield and let all turtle movements be executed by the coroutine created in bios:787 (the main thread) or do you even know a situation where the main thread is not resumed except on system restart?
Thanks for your help
Edited by Lion4ever, 23 August 2015 - 09:42 PM.