api
The Torch front door: `local Torch = require("flashlightKit.api")`. Story calls (`flicker`, `fail`, `restore`, `setCharge`, `set`, `toggle`, `setStyle`, `give`, `swap`), reads (`charge`, `isOn`, `switchedOn`, `lightOf`, `spares`, `visibility`, `lights`, `beams`, `list`), `setQual…
flashlightKit.api
The Torch front door: local Torch = require("flashlightKit.api"). Story calls (flicker, fail, restore, setCharge, set, toggle, setStyle, give, swap), reads (charge, isOn, switchedOn, lightOf, spares, visibility, lights, beams, list), setQuality, events through on(name, fn): toggled, batteryLow, batteryDead, swapped, failed, flash, charged. Owner-authoritative: calls made on another peer are sent to the torch's owner. Also holds the light model every peer computes (levelOf).
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
on(name: string, fn: (any) → void
Listen to a torch event: toggled{player,on}, batteryLow{player,charge}, batteryDead{player}, swapped{player,battery}, failed{player,mode}, flash{player}, charged{player,charge}. Returns a disconnect function. Events fire on the peer that owns the torch (the player's own machine).
| arg | type | description |
|---|---|---|
| name | string | |
| fn | (any |
_emit(name: string, payload: any) → void
| arg | type | description |
|---|---|---|
| name | string | |
| payload | any |
_register(id: string, pub: any) → St
| arg | type | description |
|---|---|---|
| id | string | |
| pub | any |
_unregister(id: string) → void
| arg | type | description |
|---|---|---|
| id | string |
_state(id: string) → St
| arg | type | description |
|---|---|---|
| id | string |
idOf(player: any) → string
| arg | type | description |
|---|---|---|
| player | any |
list( ) → void
Every torch this peer knows: { { id, mine, on, style, charge } }.
styleOf(pub: any) → any
| arg | type | description |
|---|---|---|
| pub | any |
batteryOf(pub: any) → any
| arg | type | description |
|---|---|---|
| pub | any |
curveOut(curve: string, c: number, floor: number?) → number
| arg | type | description |
|---|---|---|
| curve | string | |
| c | number | |
| floor | number? |
lowEffect(mode: string, t: number, seed: number, depth: number) → number
| arg | type | description |
|---|---|---|
| mode | string | |
| t | number | |
| seed | number | |
| depth | number |
flame(t: number, seed: number) → number
| arg | type | description |
|---|---|---|
| t | number | |
| seed | number |
levelOf(pub: any, now: number, seed: number) → number
Light output 0..~1.2 of a torch's synced fields at session time `now`. Every peer computes the same value.
| arg | type | description |
|---|---|---|
| pub | any | |
| now | number | |
| seed | number |
ownerApply(st: St, op: string, a: any, b: any, c: any) → void
| arg | type | description |
|---|---|---|
| st | St | |
| op | string | |
| a | any | |
| b | any | |
| c | any |
_hookNet( ) → void
command(player: any, op: string, a: any?, b: any?, c: any?) → boolean
| arg | type | description |
|---|---|---|
| player | any | |
| op | string | |
| a | any? | |
| b | any? | |
| c | any? |
flicker(player: any?, seconds: number?, severity: number?) → boolean
Flicker a player's torch for `seconds` (default 1.5) at `severity` 0..1 (default 0.6). Works on any peer; the owner applies it and every peer sees the same flicker.
| arg | type | description |
|---|---|---|
| player | any? | |
| seconds | number? | |
| severity | number? |
fail(player: any?, mode: string?, seconds: number?) → boolean
Make a torch fail: mode = "brownout" (fades out), "contact" (cuts in and out until the player shakes it), "sudden" (dies at once), "sputter" (sputters then dies), "flicker", "stepdown" (drops to low mode), "gutter" (flame shrinks). `seconds` = how long (nil = until Torch.restore or a shake fixes it).
| arg | type | description |
|---|---|---|
| player | any? | |
| mode | string? | |
| seconds | number? |
restore(player: any?) → boolean
Clear any failure and flicker: the torch works again (if it has charge and is on).
| arg | type | description |
|---|---|---|
| player | any? |
setCharge(player: any?, charge: number) → boolean
Set a torch's battery charge, 0..1.
| arg | type | description |
|---|---|---|
| player | any? | |
| charge | number |
charge(player: any?) → number
Battery charge 0..1 (nil if the player has no torch).
| arg | type | description |
|---|---|---|
| player | any? |
isOn(player: any?) → boolean
Whether the torch is switched on and giving light right now.
| arg | type | description |
|---|---|---|
| player | any? |
switchedOn(player: any?) → boolean
Whether the switch is on (even while a failure keeps it dark).
| arg | type | description |
|---|---|---|
| player | any? |
lightOf(player: any?) → any
The light entity of a player's torch on this peer (the spot or point light), or nil.
| arg | type | description |
|---|---|---|
| player | any? |
set(player: any?, on: boolean) → boolean
Turn a torch on or off (owner plays the click).
| arg | type | description |
|---|---|---|
| player | any? | |
| on | boolean |
toggle(player: any?) → boolean
Toggle a torch.
| arg | type | description |
|---|---|---|
| player | any? |
setStyle(player: any?, style: string) → boolean
Switch a torch's style (one field).
| arg | type | description |
|---|---|---|
| player | any? | |
| style | string |
give(player: any?, battery: string?, count: number?) → boolean
Give a player spare batteries / fuel of a type (default: the torch's own).
| arg | type | description |
|---|---|---|
| player | any? | |
| battery | string? | |
| count | number? |
swap(player: any?, battery: string?) → boolean
Swap in a spare battery (from the torch's bag or, when installed, the inventoryKit bag). Returns whether a swap was asked for.
| arg | type | description |
|---|---|---|
| player | any? | |
| battery | string? |
spares(player: any?) → number
Spare batteries of the torch's type the player carries.
| arg | type | description |
|---|---|---|
| player | any? |
visibility(player: any?) → number
How visible the player is because of their torch, 0..1: 0 dark, 1 a bright beam. Monsters can scale sight range by it.
| arg | type | description |
|---|---|---|
| player | any? |
lights(player: any?, point: vector) → number
How strongly a player's torch lights a world point, 0..1 (inside the cone and range, ignoring walls). For "the monster was caught in the beam".
| arg | type | description |
|---|---|---|
| player | any? | |
| point | vector |
beams( ) → void
Every torch currently giving light: { { id, position, forward, range, angle, kind, level } }, for AI that reacts to light.
setQuality(q: string) → void
Rendering quality: "high" (every nearby torch casts shadows), "medium" (own torch + 1 other), "low" (own torch only). Until a game calls this, the kit follows the device on its own (`M.autoQuality`); "auto" hands it back.
| arg | type | description |
|---|---|---|
| q | string |
_applyQuality(q: string) → void
| arg | type | description |
|---|---|---|
| q | string |
autoQuality( ) → string
The quality this device should run: the engine's quality tier (which a graphics setting such as graphicsPresets moves), held to "medium" on a tablet and "low" on a phone (a handheld GPU, an Android build, or a touch browser whose short side is under 1000 points).
quality( ) → string
_inventory( ) → any
_setOn(st: St, on: boolean, sound: boolean) → void
| arg | type | description |
|---|---|---|
| st | St | |
| on | boolean | |
| sound | boolean |
_setStyle(st: St, id: string) → void
| arg | type | description |
|---|---|---|
| st | St | |
| id | string |
_swap(st: St, battery: any?) → void
| arg | type | description |
|---|---|---|
| st | St | |
| battery | any? |
_station(id: string, info: any?) → void
| arg | type | description |
|---|---|---|
| id | string | |
| info | any? |
_stations( ) → void
_torches( ) → void
_shadowBudget( ) → number
St = {Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ 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".
Scoped to this part · feeds back into the world's score.