Skip to content

sys and require

sys: the system

sys.frame() → n

The frame counter. Everything that is not an actor animation takes its timing from it.

sys.ticks() → ms / sys.ticks_us() → µs

frame * 1000 / 60 and frame * 16667. Derived from the frame counter, never from the wall clock: a game must replay identically (see the rules).

sys.sin(angle) → Q16.16 / sys.cos(angle) → Q16.16

Integer sine and cosine, from a frozen quarter-turn table. The angle is an integer in 1024ths of a turn (sys.TOUR) and it wraps: no π, no radians, so no argument reduction where two platforms could diverge. sys.sin(256) is 65534, that is 0.99997.

sys.score(n)

Announces the current score. This is what the verifier reads after replaying a trace. An explicit call rather than a global read on the sly: it defines a moment and a value, and the game keeps its local score.

sys.bg_lost() → boolean

On the board, true once after a restart of RP3: its background tile map is empty, the program repaints what it had written there. In the simulator, always false.

On the board only

sys.sd(), sys.exit, sys.serial(), sys.wifi() (the state of the network, read-only), sys.json(text) (JSON into a Lua table). The system, launching a game, programming the NOR flash, pairing a gamepad, choosing the Wi-Fi network, is not in a game's API: these functions only exist for the console's dashboard.

require

require(name) → value

Loads name.lua from the game folder, once. This is not Lua's require: no package.path, no C loader, no path, a flat lowercase name ([a-z0-9_-]+, never a Windows reserved name such as con or lpt1), any /, .. or capital letter being an error. This is the rule of the console's micro-SD card (FAT32 does not distinguish case), the same as in the App. Cycles are detected.

A game's entry point is main.lua, always: it is not a setting.