⚠ SharedArrayBuffer is not available. Animation requires the COOP/COEP headers to be set. Check the _headers file and your server configuration.

LUA TURTLE

Terminal
100%

Movement

forward(n)Move forward n pixels. Alias: fd
back(n)Move backward n pixels. Alias: bk
left(degrees)Turn left. Alias: lt
right(degrees)Turn right. Alias: rt
setpos(x, y)Move to coordinates (x, y)
setheading(angle)Face a direction (0=east, 90=north). Alias: seth
home()Return to center, face east
setx(x)Set x coordinate, keep y
sety(y)Set y coordinate, keep x
teleport(x, y)Jump to position instantly, no drawing

Pen

penup()Stop drawing. Alias: pu
pendown()Start drawing. Alias: pd
pensize(n)Set line width
pencolor(r, g, b)Set color with RGB (0–1 or 0–255)
pencolor("name")Set color by name: "red", "blue", "gold", etc.
color("red")Set both pen and fill color
color("red", "blue")Set pen and fill color independently

Shapes

circle(radius)Draw a full circle
circle(radius, extent)Arc: extent in degrees

Fill

begin_fill()Start recording a filled shape
end_fill()Fill the shape drawn since begin_fill
fillcolor(r, g, b)Set fill color
dot(size)Draw a filled circle at turtle's position
dot(size, "red")Draw a dot with a specific color

Text

write(text)Write text at turtle's position
write(text, move, align, font)align: "left", "center", "right"; font: {family, size}

Canvas

bgcolor(r, g, b)Set background color
bgcolor("name")Set background color by name
clear()Erase drawing, keep turtle position
reset()Erase drawing and reset turtle to start
undo()Undo the last command
speed(n)0=instant, 1=slowest, 10=fastest

Turtle

hideturtle()Hide the turtle. Alias: ht
showturtle()Show the turtle. Alias: st
stamp()Stamp turtle shape; returns id
clearstamp(id)Remove a stamp
Turtle()Create a second turtle with all the same methods

State Queries

position()Returns x, y coordinates
xcor() / ycor()Returns x or y coordinate
heading()Returns current angle in degrees
isdown()Returns true if pen is down
isvisible()Returns true if turtle is visible
distance(x, y)Returns distance to point
towards(x, y)Returns angle towards point