▣
module · drop-in viewer
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.
by·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
| Call | What 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:
| Key | Meaning |
|---|---|
timber | scrap planks for repairs |
wire | copper wire from the generator shed |
drill | the ice drill is in hand |
trapSet, trapSetDay | the trap line is armed, and the day it was |
lampLit | the hut lamp is burning (drains lampOil) |
headlampCharge | 0..1 of the battery in the headlamp; a fresh battery is taken from batteries when it runs out |
wreckLooted, caribouTaken, caribouDay | the one-time hauls, and the day the carcass appears |
loot | scavenge point id -> units left |
lastVisitDay | gathering site -> last day gathered |
cachedFish, cachedMeat | what is in the outdoor cache |
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.