- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`) - ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk" for every build stat); Stats.base uses stats_field_name - ludic.shooter: compare aim modes and fire patterns with AimMode.* and WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y - ludic.npcai: DecisionMade / brain_set_state use AiState.* - examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and BACKDROP named; strings.ludic header says what it prints - whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only), `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every ```ludic fence reformatted with the fixed formatter (whitespace only) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
21 lines
845 B
Text
21 lines
845 B
Text
# scoped.ludic — a despawned entity drops out of subsequent event-driven work
|
|
# (replaces tests/mod_c/scoped_mod.c, which tested entity-scoped foreign callbacks
|
|
# swept on despawn). Here a @On(Tick) listener counts live Units each tick; after
|
|
# the Unit is despawned, a further tick finds none. Fires twice before the kill,
|
|
# not the third time. Prints 2.
|
|
program Scoped {
|
|
property Health { hp: int = 0 }
|
|
model Unit { Health }
|
|
var fires: int = 0
|
|
event Tick { }
|
|
@On(Tick) handler OnTick { for (Health) in query [Health, {Unit}] { fires += 1 } }
|
|
|
|
entry {
|
|
spawn Unit { Health { hp: 1 } }
|
|
emit Tick() # 1 live Unit -> fires = 1
|
|
emit Tick() # fires = 2
|
|
for (Health) in query [Health, {Unit}] { despawn self() } # kill the Unit
|
|
emit Tick() # no live Units -> fires stays 2
|
|
print(fires) # 2
|
|
}
|
|
}
|