Docs Quick code
Getting started
What Quick code is, where you type it, and a first script.
Quick code is the language you type into Code nodes (Scripts tab, Dialogue tab) and into the Code is true condition. It reads like Lua — the language of Roblox, PICO-8, LÖVE and many game mods — with the game's commands built in. If you learn it here, it carries over; and if you already know Lua, Coming from Lua lists the few differences.
It's meant to grow with you: start with one line like give("Key"), and later write
functions, tables, libraries and code that runs alongside other code — the same language all
the way.
#A first taste
A block that rises when you press E, waits, comes back down and hops three times (the Magic block in the Sample Village):
-- Rise 2 levels over 1.5 s, wait, then come back down.
self.move(0, 2, 0, 1.5)
wait(2)
self.go_home(1.5)
-- Then hop three times.
local hops = 0
for i = 1, 3 do
self.move(0, 0.5, 0, 0.2)
self.move(0, -0.5, 0, 0.2)
hops += 1
end
popup("The block hopped " .. hops .. " times!")
And one that uses more of the language — an enemy with its own health that chases the player once it's close:
-- On the enemy's script, Event: "Player enters the level".
self.hp = 30
function hit(amount)
self.hp -= amount
self.say("Ouch! " .. self.hp .. " left")
if self.hp <= 0 then
self.remove()
end
end
on("touched", function()
hurt(5) -- the player touched it: 5 damage to the player
hit(10) -- …and it takes 10 itself
end)
while self.exists do
if self.distance(player) < 6 then
self.follow(player, 3)
else
self.stop()
end
wait(0.25)
end
#Where code runs
| Place | How it runs |
|---|---|
| Code node in a script (Scripts tab) | When the script reaches it. It can wait(); then the script goes on to the next node. |
| Code node in a dialogue | All at once: waits are skipped (the conversation can't pause mid-node). |
| Code is true condition | One expression, e.g. wishes >= wishes_needed — in Condition nodes, Trigger conditions and dialogue answers. |
| A library script | Its functions, for any code to use with require("Name") — see Libraries. |
Scripts start from Event nodes: the player presses E, touches it, enters the level, it's destroyed, every few seconds, a key is pressed, a message is sent, or another script calls it. Put a script on an object by dropping it from the Scripts tab onto the object (or Properties ▸ Script). A script on the ground of a level (World settings ▸ Scripts) runs for the whole level.
#The editor helps
- Colours show what each name is: game variables green, functions blue, keywords purple,
self/player/otheryellow, and anything the code doesn't know orange-red — usually a typo. A quoted name that should exist (has("Oaken Staff"),object("gate"),play("door")) turns green when the game has it and red when it doesn't; hover an item name to see its icon. - Autocomplete: the rest of a name shows in grey after the caret; Tab finishes it.
- Insert ▾ lists everything: blocks (if, loops, functions, tables), every game function by group, the language's own functions, and object commands. Hover an entry for its help.
- Check lists mistakes and warnings with line numbers — see Checking and debugging.
- ⤢ opens the code big; Ctrl + wheel sets the text size.