ludic/packages/ludic.fire/system.ludic
Orkuncakilkaya 0af0ef681f ludic.fire: a camp fire's fuel, lit and out, the rain on it, and its reach
Minutes of fuel that burn down in game time, twice as fast in the rain with
nothing over the ring, and the hours it held under cover. Lighting and feeding
are decided (fire_decide), costed in wood (fire_cost) and applied
(fire_apply) apart, so a machine that does not own the world can ask the one
that does. Warmth and cooking by distance are queries. FIRE_LIT,
FIRE_WENT_OUT and FIRE_LOW_FUEL are facts; the rain, the tarp, the ban and
who owns the world come through the FireWorld port. Its own save section.
Uses ludic_base only; 8 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 06:08:53 +03:00

26 lines
703 B
Text

# system.ludic - the fire as a system: PH_SIMULATE, and its own save section
function fire_tick(t: Tick) -> void { fire_run(t.hours) }
export function fire_save() -> Val {
let v = Value.object()
sv_put_bool(v, "lit", fr_lit)
sv_put_float(v, "fuel", fr_fuel)
sv_put_float(v, "rain_h", fr_rain_h)
return v
}
export function fire_load(v: Val, version: int) -> void {
fire_reset()
fr_lit = sv_bool(v, "lit", false)
fr_fuel = sv_float(v, "fuel", 0.0)
fr_rain_h = sv_float(v, "rain_h", 0.0)
}
export function fire_system() -> System {
let s = system_new("fire", PH_SIMULATE)
s.reset = fn fire_reset
s.tick = fn fire_tick
s.save = fn fire_save
s.load = fn fire_load
return s
}