Forums > Jitter

Internal state of jit.turtle

July 13, 2012 | 1:47 pm

I’ve been having a lot of fun playing around with jit.turtle and am wondering if it is possible to get it to report its internal position and heading with something like a getstate message.

I know that getstate reports origin, angle, scale and clearmode. If you use a command like F, jit.turtle will output a linesegment message and the turtle’s current position can be extracted from that message. But most commands (like f, +, -) change an internally-represented position or heading and you won’t know what the intermediate states are until you execute the next F command.

The approach that I am taking is to preprocess all commands before they go to jit.turtle and to keep track of position and heading outside of the turtle routine.

This may seem like a weird request, but having jit.turtle report on the current heading and position allows you to composite an image of the turtle itself on the drawing (like the ‘hide turtle’ and ‘show turtle’ commands of LOGO). It also makes it easier to write programs that depend on the interaction of two or more turtles in real time.


Viewing 1 post (of 1 total)