Jump to content




At what point is the turtle pos updated?


2 replies to this topic

#1 Qauzzix

  • New Members
  • 1 posts

Posted 27 February 2013 - 03:18 AM

Title: At what point is the turtle pos updated?

The scenario I am thinking about is when the current running coroutine is a turtle code that is about to call a movement function. When the coroutine yields no other coroutines will get execution ( as I understand it ). Is the position and direction of the turtle modified when the turtle code gets execution again or before? I would assume that the movement would never take place if the last running coroutine calls the movement function that will yield until the movement is completed. But assumptions can make bad bugs. At what point during code execution is the turtle location and directions actually updated?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,462 posts

Posted 27 February 2013 - 04:21 AM

Split into new topic.

You can update the position whenever you want; the turtle's location will generally be wherever you told it to be last, except that you might not see the success/failure event come back to let you know whether the move succeeded.

#3 ChunLing

  • Members
  • 2,027 posts

Posted 28 February 2013 - 03:49 AM

That is to say, if you are using the turtle functions rather than the turtle.native functions, the turtle is where it is before the movement until the function is called, then the function is running, and then the turtle is where it is after the function.

If you want, you can probably write a version of the turtle movement functions (using the native functions) that uses short timers to "pre-check" if a turtle movement is successful, since false returns on moves are basically instant. If the move doesn't fail, then I believe that the change in position/facing should have been initiated successfully and the turtle is just waiting for the event saying that the animation has finished and the turtle is ready for another move.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users