For the complete documentation index, see llms.txt. This page is also available as Markdown.

init and main

init runs once. main runs continuously. Both operate on the same globals.

Zen Studio Live accepts multiple init and multiple main sections. The compiler merges each set into a single initialization phase and a single repeating main phase. This is useful for generated or combined source, although one init and one main are easier to read in hand-written scripts.

Use init for:

  • loading persistent values;

  • platform selection;

  • one-time cache initialization;

  • setting initial state.

Use main for:

  • reading current input;

  • detecting events;

  • advancing state machines;

  • calculating the current output report;

  • drawing only when a dirty flag says the display changed.

Last updated