full language ref, 1337 as ↗
lifecycle
on init do
// runs once on load or script change
// set up sprites and starting values here
end
on tick do
// runs ~6x per second — your game loop
end
ui namespaces
// buttons: prefix function names with btn.
on btn.feed do
add 5 to ui.hunger
end
// dashboard: anything in ui.* shows as a stat chip
put 10 into ui.hunger // displays "hunger 10"
put 3 into ui.mood // displays "mood 3"
sprites
// draw 16x16 pixel art with X = on, . = off
sprite myface
................
................
................
.....XXXXXX.....
...XX......XX...
..X..X....X..X..
.X...X....X...X.
.X............X.
.X..XX....XX..X.
.X..XX....XX..X.
..X....XX....X..
...XX.....XXX...
.....XXXXXX.....
....XX....XX....
...XX......XX...
................
................
end-sprite
put sprites.myface into display.pixels
animation
// use a flag so buttons show visible feedback
// even though tick runs every 150ms
on btn.poke do
put 12 into _excited // tick will read this
end
on tick do
cond _excited > 0 do shuffle display.pixels,
else do put sprites.stand into display.pixels
when _excited > 0 do sub 1 from _excited
end
core language bits
put 10 into score // set a value
add 1 to score // increment
sub 1 from score // decrement
clamp score min 0 max 10 // constrain
when score > 5 do set happy // conditional
roll 6 into dice // random 1–6
shuffle display.pixels // randomize list
map arr do add 1 to it // transform each item
str.replace key "a" "b" // replace all in string
multi-branch conditionals
// first matching branch wins — must end with else
// branches are separated by commas, not newlines
cond score > 9 do put "A" into grade,
score > 7 do put "B" into grade,
else do put "C" into grade
flags
set alive // alive = true
unset alive // alive = false
toggle muted // flip between true and false
wipe temp // delete the key entirely
unless and has
// unless fires when the condition is NOT true
unless lives > 0 do set dead
// has checks if something is in a list or string
when inventory has sword do set armed
when status has burn do sub 1 from hp
show values in text
// wrap {key} in a string to embed its value
put "HP: {hp}" into ui.status // shows "HP: 10"
put "{name} wins!" into ui.msg // dot-paths work too: {player.name}
more math
mul 2 by score // score x 2
div 4 into hp // hp / 4
math.floor ratio // 7.9 -> 7
math.round ratio // 7.5 -> 8
math.abs delta // -5 -> 5
lists
push 5 onto scores // add to the end
list 3 1 4 into nums // build a list from scratch
range 1 to 5 into steps // [1, 2, 3, 4, 5]
sort scores // lowest first
rev scores // flip the order
count scores into n // how many items -> n
sum scores into total // add them all up -> total
filter and find
// filter keeps every match; find returns just the first
filter enemies where hp > 0 into alive
find enemies where hp > 0 into leader
each — loop over a list
// map replaces each item; each lets you accumulate into other keys
each enemies do sub player.atk from it.hp
each units do add it.atk to total_damage // it = current item
function arguments
on heal amount do
add amount to hp
clamp hp min 0 max 10
end
heal 5 // hp += 5
heal max_potion // passes the value of max_potion
log — peek at state
// appends a message to state._log[] each time it runs
// check it via the browser console or time scrubber
log tick is _tick hunger is ui.hunger