Turtle Script

Turtle Script is parsed within the logic panel of 2D shape nodes.

Use a new line of script for each command.
The turtle can only read/write the parameters on its own node.

Values inside () are optional.

newpnew point creates a vertex in-situ and restarts the UV map
mov x y (a)move to x y (degrees)
teleport turtle to location (face direction)
drw x ydraw to location x y
dir adirection angle in degrees
0 is east, 90 is north
bezier ax ay ahx ahy bhx bhy bx by segmentscubic bezier with 2 handles
start handle1 handle2 end segments
molding type ax ay bx by segments tensionpoint-to-point tension curves
type* start end segments tension
*type: cove, ovolo, cymarecta, cymareversa, dome
rmov dx dyrelative move offset-x offset-y
teleport to offset, restarts the UV map
*shape must be OPEN
rdrw dx dyrelative draw offset-x offset-y
movfwd c (d)move forward value (offset)
*shape must be OPEN
fwd c (d)forward value (offset)
back c (d)back value (offset)
right c (d)right value (offset)
left c (d)left value (offset)
turnl arotate counter-clockwise degrees
turnr arotate clockwise degrees
arcr angle radius segmentsdraw an arc to the right
angle in degrees
of the arc
(int) line segments
arcl angle radius segmentsdraw an arc to the left
angle in degrees
radius of the arc
segments (int) line segments
closed true
closed false
adds a segment connecting the last point to the first, and removes overlapped vertices
*required for ‘manifold topology’
*changes options under Shape Output
*also a bool switch under Shape Output
setset the value on a parameter or variable
set parameter value
set var value
letcreate a temporary variable
let var value
loop repeat (count) (step)open a loop and repeat (int) until done
(count) create temp var (int) = the loop value
(step) steps through the count by (int)

loop 360 rotate 90
dir rotate
// rotate = 0, 90, 180, 270
endloopterminate loop
if conditionalopen a conditional directive when true
if parameter GT value
var GT value
var LT value
var GE value
var LE value
var EQ value
var NE value
greater than
less than
greater or equal
lesser or equal
not equal
if boolrun conditional when bool is true
if !boolrun conditional when bool is false
endifterminate conditional
//comment line

subtract (negative)
order of operations
mathf functionsfunction returns a value
parameterthe value of a parameter
mov width 0
set width value
DetailLevelread-only parameter from graph: 0-1
*reduces segments on all nodes: 0.5 is 50%
*generate LOD models by reducing vertices
if DetailLevel LT .67

Example scripts:

The best way to learn AX Turtle Script is to open the Logic panel on any 2D shape to see how it was made.

mov width/2 0 90
drw 0 height/2
drw –width/2 0
drw 0 –height/2

Output Shape: closed
if shift_origin
molding cove –width height 0 0 segs tension

if !shift_origin
molding cove 0 height width 0 segs tension

Output Shape: open
if inputHypotenuse
if solveWidth
set width Sqrt(hypotenuse*hypotenuseheight*height)
set height Sqrt(hypotenuse*hypotenusewidth*width)

set hypotenuse Sqrt(width*width+height*height)
set theta Atan2(height,width)
mov 0 0 90
right width
fwd height

Output Shape: closed
if bX GE aX
let mdX abs(bXaX)/(segs-1)
if bX LT aX
let mdX -abs(bXaX)/(segs-1)
if bY GE aY
let mdY abs(bYaY)/(segs-1)
if bY LT aY
let mdY -abs(bYaY)/(segs-1)
if cX GE bX
let ndX abs(cXbX)/(segs-1)
if cX LT bX
let ndX -abs(cXbX)/(segs-1)
if cY GE bY
let ndY abs(cYbY)/(segs-1)
if cY LT bY
let ndY -abs(cYbY)/(segs-1)

mov aX aY
loop segs i
mov aX+mdX*i aY+mdY*i
drw bX+ndX*i bY+ndY*i

Output Shape: open

Comments are closed.