newTown(id: string) → Town
| arg | type | description |
|---|
| id | string | |
newBuilding(id: string, kind: string, town: string) → Building
| arg | type | description |
|---|
| id | string | |
| kind | string | |
| town | string | |
town(works: any, id: string) → Town
| arg | type | description |
|---|
| works | any | |
| id | string | |
cap(works: any, townId: string, res: string) → number
How much of `res` a town can keep: the resource's own limit plus every storage building of the town (scaled by its level). math.huge for uncapped resources and currencies.
| arg | type | description |
|---|
| works | any | |
| townId | string | |
| res | string | |
caps(works: any, townId: string) → void
Every limit of a town, for every resource the kit knows (uncapped ones left out).
| arg | type | description |
|---|
| works | any | |
| townId | string | |
order(works: any) → void
| arg | type | description |
|---|
| works | any | |
affordable(stock: { [string]: number }, need: { [string]: number }) → void
| arg | type | description |
|---|
| stock | { [string]: number } | |
| need | { [string]: number } | |
hasRoom(works: any, town: Town, outputs: { [string]: number }, caps: { [string]: number }) → boolean
| arg | type | description |
|---|
| works | any | |
| town | Town | |
| outputs | { [string]: number } | |
| caps | { [string]: number } | |
deposit(town: Town, b: Building, outputs: { [string]: number }, scale: number, got: { [string]: number }) → void
| arg | type | description |
|---|
| town | Town | |
| b | Building | |
| outputs | { [string]: number } | |
| scale | number | |
| got | { [string]: number } | |
take(town: Town, inputs: { [string]: number }) → void
| arg | type | description |
|---|
| town | Town | |
| inputs | { [string]: number } | |
setStatus(b: Building, status: string, missing: { [string]: number }?, ev: { any }?) → void
| arg | type | description |
|---|
| b | Building | |
| status | string | |
| missing | { [string]: number }? | |
| ev | { any }? | |
stepRecipe(works: any, b: Building, k: any, town: Town, dt: number, speed: number, yieldScale: number, caps: any, ev: { any }?) → void
| arg | type | description |
|---|
| works | any | |
| b | Building | |
| k | any | |
| town | Town | |
| dt | number | |
| speed | number | |
| yieldScale | number | |
| caps | any | |
| ev | { any }? | |
stepQueue(works: any, b: Building, k: any, town: Town, dt: number, speed: number, caps: any, ev: { any }?) → void
| arg | type | description |
|---|
| works | any | |
| b | Building | |
| k | any | |
| town | Town | |
| dt | number | |
| speed | number | |
| caps | any | |
| ev | { any }? | |
step(works: any, dt: number, opts: any?) → void
Advance every building of a works by dt seconds. opts.speed multiplies every building's speed; opts.yield multiplies what cycles give (offline efficiency); opts.events = false skips the event list. Returns the events: { kind = "made" | "status" | "jobDone", b = buildingId, ... }.
| arg | type | description |
|---|
| works | any | |
| dt | number | |
| opts | any? | |
snapshot(works: any) → any
| arg | type | description |
|---|
| works | any | |
catchUp(works: any, seconds: number, opts: any?) → any
Run a long stretch of time in chunks (offline earnings) and say what it made. seconds is already capped by the caller; opts.yield scales what it makes (offline efficiency), opts.speed as in step, opts.steps the most chunks (default 3000). Returns { seconds, towns = { [townId] = { made = {..}, used = {..}, paid = {..} } }, jobs = { {b, job, uid, by} } }.
| arg | type | description |
|---|
| works | any | |
| seconds | number | |
| opts | any? | |
enqueue(works: any, id: string, jobId: string, uid: string, by: string?) → void
Put a job at the back of a building's queue, taking its non-currency costs from the town's stock. Returns ok, code, entry. Codes: noBuilding, noQueue, noJob, queueFull, missing (values.missing).
| arg | type | description |
|---|
| works | any | |
| id | string | |
| jobId | string | |
| uid | string | |
| by | string? | |
cancel(works: any, id: string, which: any) → any
Take a job out of a building's queue by its uid (or its position) and give back the goods it took. Returns the entry, or nil when there is none. The first job's progress is lost when it is cancelled.
| arg | type | description |
|---|
| works | any | |
| id | string | |
| which | any | |
takePending(town: Town) → void
Pay a town's whole pending currency amounts out (whole numbers only; fractions stay pending). Returns { [currency] = amount }.
| arg | type | description |
|---|
| town | Town | |
rates(b: Building, speedAll: number?) → any
Per-second rates a building gives and takes at its level when working: { outputs = {..}, inputs = {..} }. For a queue building, its front job.
| arg | type | description |
|---|
| b | Building | |
| speedAll | number? | |
cycleTime(b: Building, speedAll: number?) → number
Seconds one cycle (or the front job) takes at the building's level.
| arg | type | description |
|---|
| b | Building | |
| speedAll | number? | |