The basics
Functions every script has, whatever it does.
print(...)Writes its values to the script output, with a space between them.
warn
warn(...)Like print, in yellow: for something that looks wrong but doesn't stop the script.
error
error(message, level?)Stops the task with a message, which shows red in the script output with the line it happened on. pcall can catch it. A level of 0 leaves the line out.
assert
assert(value, message?)Stops with the message when the value is false or nil; else gives the value back.
pcall
pcall(f, ...)Calls f with the values after it and catches what goes wrong: gives true and f's results, or false and the error.
xpcall
xpcall(f, handler, ...)Like pcall, but an error is given to handler first, and what handler gives back is the second result.
wait
wait(seconds?)Pauses this task: for that many seconds, or until the next step of the level with no number. Gives back how long it really waited.
beats
beats(n)How many seconds n beats of the song take: wait(beats(2)) waits two beats.
tween
tween(what, properties, seconds?, ease?, direction?)Glides numbers of a thing, the camera or the player to new values: tween(door, {y = 4, alpha = 0}, 1.5, "quad", "out"). Gives back an event that happens when it has arrived.
type
type(value)What kind of value it is, as a string: "nil", "boolean", "number", "string", "table", "function", "thread", or one of the game's kinds such as "thing" and "event".
tostring
tostring(value)The value as a string. A table whose metatable has __tostring is asked for its own.
tonumber
tonumber(value, base?)The number a string spells, or nil when it spells none. With a base (2 to 36) the string is read in that base.
pairs
pairs(table)For a for loop: every key and value of a table. for key, value in pairs(t) do ... end (for key, value in t do ... end does the same).
ipairs
ipairs(list)For a for loop: a list's items in order, 1, 2, 3..., up to the first nil.
next
next(table, key?)The key after this one in a table and its value (the first ones, with no key); nil after the last.
select
select(n, ...)The values from the nth on; select("#", ...) is how many there are.
unpack
unpack(list, from?, to?)A list's items as separate values (the same as table.unpack).
rawget
rawget(table, key)A table's value for a key, without asking its metatable.
rawset
rawset(table, key, value)Sets a table's value for a key, without asking its metatable.
rawequal
rawequal(a, b)Are the two the very same value? (Without asking a metatable's __eq.)
rawlen
rawlen(value)The length of a table or a string, without asking a metatable's __len.
setmetatable
setmetatable(table, metatable)Gives a table a metatable (or takes it away with nil): the table that says what +, .., ==, calling it or reading a missing key do. Gives the table back.
getmetatable
getmetatable(table)A table's metatable, or nil.
collectgarbage
collectgarbage()How much memory the level's scripts keep right now, in KB. (The game tidies up by itself.)
shared
This script's table for the others: what it puts in shared, another script reads as scripts.<this script's name>.
scripts
The other scripts' shared tables, by name: scripts.door.open() calls the function the script door put in its shared table.