A clean script skeleton
// 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;
}Last updated

