Log inGet started
World

First Light

Branchmain
Branchesmain
Commit5b1bfa8dc1

README.md

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