Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld b0f23b4e-e…

stores

What the survivor has. The numbers live on `Rules.state.stores`; this module is the one door every change goes through, so every change clamps at zero and emits the `stores` event.

byPolar Night·posted 1mo ago
What it does

firstlight.stores

What the survivor has. The numbers live on Rules.state.stores; this module is the one door every change goes through, so every change clamps at zero and emits the stores event.

local Stores = require("firstlight.stores")
Stores.add("tins", 1)        --> total, and emits stores { key = "tins", delta = 1, total = 11 }
Stores.take("matches", 1)    --> true when there was one to take
Stores.has("batteries")      --> true when at least one
Stores.food()                --> meals in hand: tins + fish + meat

API

CallWhat it does
Stores.add(key, delta)Change a store; negative spends. Never below zero. Returns the total, emits stores.
Stores.set(key, value)Set outright. Emits stores.
Stores.get(key)Read a number (0 when unset).
Stores.has(key, n?) / Stores.take(key, n?)Check for, or spend, n (default 1).
Stores.food() / Stores.foodKg()Meals in hand, and their weight in kg.
Stores.cacheOutside() / Stores.bringInside()Move raw fish and meat to the cache outside the hut door and back. foodOutside is what the bear smells.
Stores.lootLeft(id, initial) / Stores.lootTake(id, initial)Units left at a scavenge point, seeded on first ask.
Stores.visitedToday(key) / Stores.markVisited(key)Once-a-day gathering sites.
Stores.ensure()Seed the fields below on the blackboard. firstlight.sites calls it at awake.

Keys on Rules.state.stores

Seeded by firstlight.rules: tins, fuel (kg wood-equivalent, what the stove burns), lampOil (litres), batteries, matches, fish, meat, foodOutside (kg), headlampOn, holeDrilled.

Added by this slice:

KeyMeaning
timberscrap planks for repairs
wirecopper wire from the generator shed
drillthe ice drill is in hand
trapSet, trapSetDaythe trap line is armed, and the day it was
lampLitthe hut lamp is burning (drains lampOil)
headlampCharge0..1 of the battery in the headlamp; a fresh battery is taken from batteries when it runs out
wreckLooted, caribouTaken, caribouDaythe one-time hauls, and the day the carcass appears
lootscavenge point id -> units left
lastVisitDaygathering site -> last day gathered
cachedFish, cachedMeatwhat is in the outdoor cache

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

strict

stores( ) → void

ensure( ) → void

Ensure every field this slice reads exists on the blackboard.

get(key: StoreKey) → number

argtypedescription
keyStoreKey

add(key: StoreKey, delta: number) → number

Change a store by `delta` (negative to spend). The result never drops below zero. Returns the new total, and emits `stores { key, delta, total }` with the delta that was actually applied.

argtypedescription
keyStoreKey
deltanumber

set(key: StoreKey, value: number) → number

Set a store outright.

argtypedescription
keyStoreKey
valuenumber

has(key: StoreKey, n: number?) → boolean

True when at least `n` (default 1) of a store is in hand.

argtypedescription
keyStoreKey
nnumber?

take(key: StoreKey, n: number?) → boolean

Spend `n` of a store if it is there. Returns whether it was.

argtypedescription
keyStoreKey
nnumber?

food( ) → number

Meals in hand.

foodKg( ) → number

Kilograms of food a bear could smell if it were left outside.

cacheOutside( ) → number

Move raw fish and meat to the cache outside the hut door. What is outside is what the bear is drawn to; tins stay inside because they do not smell. Returns the kg now outside.

bringInside( ) → number

Bring the cached food back in. Returns the meals recovered.

lootLeft(id: string, initial: number) → number

Units left at a scavenge point, seeded from `initial` the first time it is asked.

argtypedescription
idstring
initialnumber

lootTake(id: string, initial: number) → number

Take one unit from a scavenge point. Returns the units left, or nil when it was empty.

argtypedescription
idstring
initialnumber

visitedToday(key: string) → boolean

The last day a per-visit site was gathered, and marking today as that day.

argtypedescription
keystring

markVisited(key: string) → void

argtypedescription
keystring
⌬ Types
StoreKey = string

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

7items
▣
module · born here
❒asset
# firstlight.rules The one module every part of First Light requires: `require("firstlight.rules")`. It holds the game's numbers (day length, temperatures, calorie burn, stove fuel rates, bear ranges, starting stores), the layout of the station and the sites around it, the shared blackboard `M.state`, the event bus `M.events`, and the clock. ## The clock `M.tick(dt)` is called once per play frame by the scene entrypoint. It advances `M.state.run.elapsed`, derives `M.state.clock` (day, fraction of day, hour, sun elevation, twilight openness) and emits `day`, `noon` and `firstLight`. `M.sleepToMorning()` jumps to 07:00 next day; `M.restore(elapsed)` rebuilds the clock from a persisted run. Pure helpers: `sunElevation(day, t)`, `twilightSeconds(day)`, `airC(day, t)`, `windChill(airC, windMs)`, `progress(day)`, `rng(seed, salt)`, `dist2d`. ## The blackboard `M.state` has one section per slice. A slice writes its own section and reads the others: `run`, `clock`, `weather`, `body`, `hut`, `stores`, `bear`, `journal`. ## Events `M.events.on(name, fn)` returns an unsubscribe function; `M.events.emit(name, payload)` calls every listener. The names and payloads are listed at the top of `init.luau`. `M.say(text, seconds)` emits `say` for the HUD.
▲ 0↑ born
backing path · firstlight/stores.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.