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

A clean script skeleton

clean-script-skeleton.gpc
// Compile-time names
define DEFAULT_STRENGTH = 20;

// Immutable data
const int8 RESPONSE_TABLE[] = { 0, 5, 10, 20, 35, 55, 80, 100 };

// Runtime state: global only
int enabled;
int strength = DEFAULT_STRENGTH;
int fire_button;

// One-time setup
init {
    fire_button = PS5_R2;
}

// Real-time loop
main {
    if(event_press(PS5_CROSS)) {
        enabled = !enabled;
    }

    if(enabled && get_ival(fire_button)) {
        set_val(TRACE_1, strength);
    }
}

// User functions conventionally follow main
function bounded_add(value, amount, low, high) {
    value = value + amount;
    if(value < low) return low;
    if(value > high) return high;
    return value;
}

The compiler does not require every optional section or this exact order, but consistent structure makes ownership and execution order reviewable.

Last updated