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

missionRunner

Runs authored work from data: steps with goals, fails, limits and

byzero-proxy @ DESKTOP-DB3UJOJ·posted 11d ago
What it does

missionRunner

Runs authored work from data: steps with goals, fails, limits and

checkpoints, a twist, CHOICES that branch what follows, bonus objectives, and the rewards all of that adds up to.

One runner runs story missions; a second runs activities (the same data shape, see content.missions and
content.activities). It evaluates conditions against facts the game supplies each tick and events the game
reports as they happen. It applies nothing itself: every moment goes out on the hub with the step's or twist's
`stage` directions for the host to act on, and the finished job's rewards for the game to pay.

  local Runner = require("metropolisGame.logic.missionRunner")
  local r = Runner.new(Missions.list, hub, { name = "mission" })      -- name prefixes the hub events
  r:available({ done = {...}, rank = 1, colour = { old_quay = 12 }, upgrades = {}, painted = 0, flags = {}, trust = {} })
  r:start("proper_piece")
  r:event("bought", { tins = 6 })
  r:choose("bargain")                       -- answers a `choose` step (false when no such option is on offer)
  local status = r:tick(dt, facts)          -- "idle" | "running" | "done" | "failed"
  r:retry()                                 -- back to the last checkpoint step (after "failed")
  r:abandon()
  r:view()    -- { id, step, count, limit = { left, duration }?, twisted, failed, options = { id }?, chosen = {} } or nil
  r:serialise()   r:restore(data)           -- the active job, its checkpoint and choices, and what is done
  r.done      -- { [id] = true }            r.chosen -- { [id] = { choice, ... } } what was chosen in finished jobs

A step: { goal, fail?, limit?, checkpoint?, stage?, teach?, vars?, when = { chose = "x" }?, choose = { "x", "y" }? }
  when.chose   the step only exists on the branch where that option was chosen (otherwise it is skipped)
  choose       the step is a decision: it completes when `r:choose(option)` is called (goal is ignored)
A job: { id, steps, twist?, requires?, rewards?, rewardsBy = { [choice] = rewards }?,
         bonus = { { id, goal, rewards } }? (checked every tick; each can be earned once),
         failRewards? (applied when an activity fails: consequences are part of the design) }

Hub events ("<name>" = the runner's name): "<name>Started" { id }, "<name>Step" { id, step, stage, teach, vars,
options }, "<name>Twist" { id, stage, teach }, "<name>StepDone" { id, step }, "<name>Chose" { id, step, choice },
"<name>Bonus" { id, bonus }, "<name>Done" { id, rewards = { rewards, ... }, choices, bonuses },
"<name>Failed" { id, step, why, rewards }.
Runner.test(cond, facts, events, time) is the condition evaluator (see content.missions for the vocabulary).

The interface is documented in the header of init.luau; this file repeats it for the asset browser.

Interface

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

conforms to

zero/source-extract/v2

metropolisGame.logic.missionRunner — runs authored work from data: steps with goals, fails, limits and checkpoints, a twist, CHOICES that branch what follows, bonus objectives, and the rewards all of that adds up to. One runner runs story missions; a second runs activities (the same data shape, see content.missions and content.activities). It evaluates conditions against facts the game supplies each tick and events the game reports as they happen. It applies nothing itself: every moment goes out on the hub with the step's or twist's `stage` directions for the host to act on, and the finished job's rewards for the game to pay. local Runner = require("metropolisGame.logic.missionRunner") local r = Runner.new(Missions.list, hub, { name = "mission" }) -- name prefixes the hub events r:available({ done = {...}, rank = 1, colour = { old_quay = 12 }, upgrades = {}, painted = 0, flags = {}, trust = {} }) r:start("proper_piece") r:event("bought", { tins = 6 }) r:choose("bargain") -- answers a `choose` step (false when no such option is on offer) local status = r:tick(dt, facts) -- "idle" | "running" | "done" | "failed" r:retry() -- back to the last checkpoint step (after "failed") r:abandon() r:view() -- { id, step, count, limit = { left, duration }?, twisted, failed, options = { id }?, chosen = {} } or nil r:serialise() r:restore(data) -- the active job, its checkpoint and choices, and what is done r.done -- { [id] = true } r.chosen -- { [id] = { choice, ... } } what was chosen in finished jobs A step: { goal, fail?, limit?, checkpoint?, stage?, teach?, vars?, when = { chose = "x" }?, choose = { "x", "y" }? } when.chose the step only exists on the branch where that option was chosen (otherwise it is skipped) choose the step is a decision: it completes when `r:choose(option)` is called (goal is ignored) A job: { id, steps, twist?, requires?, rewards?, rewardsBy = { [choice] = rewards }?, bonus = { { id, goal, rewards } }? (checked every tick; each can be earned once), failRewards? (applied when an activity fails: consequences are part of the design) } Hub events ("<name>" = the runner's name): "<name>Started" { id }, "<name>Step" { id, step, stage, teach, vars, options }, "<name>Twist" { id, stage, teach }, "<name>StepDone" { id, step }, "<name>Chose" { id, step, choice }, "<name>Bonus" { id, bonus }, "<name>Done" { id, rewards = { rewards, ... }, choices, bonuses }, "<name>Failed" { id, step, why, rewards }. Runner.test(cond, facts, events, time) is the condition evaluator (see content.missions for the vocabulary).

matches(e: any, cond: any) → boolean

argtypedescription
eany
condany

test(cond: any, facts: any, events: any, time: number) → boolean

Evaluate a condition. `events` is { [name] = { payload, ... } } since the step began; `time` seconds in it.

argtypedescription
condany
factsany
eventsany
timenumber

new(jobs: { any }, hub: any?, opts: any?) → any

A runner over a list of job definitions. opts = { name = "mission" }.

argtypedescription
jobs{ any }
hubany?
optsany?

emit(self: any, event: string, payload: any) → void

argtypedescription
selfany
eventstring
payloadany

meets(requires: any?, progress: any) → boolean

Whether a job's `requires` are met by a progress summary: { missions = { id }, rank, colour = { [district] = n }, upgrades = { id }, painted = n, flags = { name }, trust = { [contact] = n }, chose = { [jobId] = choice } }.

argtypedescription
requiresany?
progressany

available(progress: any) → void

The jobs that can be started now, in list order.

argtypedescription
progressany

onBranch(a: any, s: any) → boolean

argtypedescription
aany
sany

enter(self: any, step: number) → void

argtypedescription
selfany
stepnumber

start(id: string) → boolean

Begin a job. Returns false if it is unknown or another is running.

argtypedescription
idstring

event(name: string, payload: any?) → void

Report something that happened. Ignored when nothing is running.

argtypedescription
namestring
payloadany?

choose(option: string) → boolean

Answer the decision the running job is waiting on. Returns false when that option is not on offer now.

argtypedescription
optionstring

rewardsOf(m: any, a: any) → void

argtypedescription
many
aany

finish(self: any) → string

argtypedescription
selfany

tick(dt: number, facts: any) → string

Advance the running job.

argtypedescription
dtnumber
factsany

retry( ) → number

After a failure: start again from the last checkpoint. Returns the step, or nil when nothing had failed.

abandon( ) → void

view( ) → any

What a HUD needs about the running job, or nil.

serialise( ) → any

restore(data: any) → void

Restore from serialise(). A running job resumes at its checkpoint.

argtypedescription
dataany

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.