api
`tensionKit.api` (`require("~tensionKit.api")`) is the tension director's public surface: the per-player dread level (0..1) and its band, the inputs a game feeds it (`stimulus`, `setThreat`, `setSafe`, `setHiding`, `setTorch`, `setBattery`, `setHealth`, `setLight`), the pacing ga…
api
tensionKit.api (require("~tensionKit.api")) is the tension director's public surface: the per-player dread level (0..1) and its band, the inputs a game feeds it (stimulus, setThreat, setSafe, setHiding, setTorch, setBattery, setHealth, setLight), the pacing gate scaresKit asks (canScare, scared, suggestScare), the one-field style switches (setPacing, setLook, setPalette, setOutputs), the events (on("level"|"band"|"peak"|"safe"|"stimulus"|"scare")) and the tuning readout (debug). Game code, horrorKit, scaresKit and monster kits call it; the DreadDirector host ticks it.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2tensionKit's public API: the tension director. One dread level (0..1) per player, built from silence, darkness, noises, threats, low health, low battery and scares, eased by light, calm and safe rooms. Gates scares with pacing rules (minimum gap, breather, intensity budget) and drives the optional outputs (music, ambience, heartbeat, breathing, screen and camera feel). local Dread = require("~tensionKit.api") Dread.start({ pacing = "slowBurn", look = "grain70s", palette = "deepSea" }) Dread.stimulus("slam", 1) -- a door slammed next to the player Dread.setThreat(12) -- a monster 12 m away (or 0..1) if Dread.canScare(3) then ... Dread.scared(3) end Dread.on("peak", function() print("terror") end)
fresh( ) → any
emit(name: string, payload: any) → void
| arg | type | description |
|---|---|---|
| name | string | |
| payload | any |
on(name: string, fn: (any) → void
Listen to a tensionKit event on this player's engine. Events: `level{value,band}` (on band changes and every 0.05 of movement), `band{band,previous,value}`, `peak{value}` (dread crossed the peak), `safe{on}`, `stimulus{kind,amount,value}`, `scare{intensity}`. Returns disconnect.
| arg | type | description |
|---|---|---|
| name | string | |
| fn | (any |
hostComponent( ) → string
ensureHost( ) → void
Make sure this engine's director host runs (play mode only). Every call that needs time to pass makes sure of it, so placing the DreadDirector component is optional.
_attach(id: string) → void
| arg | type | description |
|---|---|---|
| id | string |
_detach(id: string) → void
| arg | type | description |
|---|---|---|
| id | string |
setPacing(name: string) → void
Pick the pacing style (one field): slowBurn, rollercoaster, relentless, quietDread, survivalClassic, arcade.
| arg | type | description |
|---|---|---|
| name | string |
setLook(name: string) → void
Pick the screen-feel look (one field): clean, grain70s, vhs, coldMonitor, sickly, bleachBypass.
| arg | type | description |
|---|---|---|
| name | string |
setPalette(name: string) → void
Pick the audio palette (one field): industrial, deepSea, organic, synth, classic.
| arg | type | description |
|---|---|---|
| name | string |
setOutputs(t: { [string]: boolean }) → void
Switch outputs on or off: `{ music, ambience, heartbeat, breathing, screen, camera, stingers }`.
| arg | type | description |
|---|---|---|
| t | { [string]: boolean } |
configure(opts: any) → void
Everything at once: `{ pacing, look, palette, outputs = {...}, autoSense, debugKey }`.
| arg | type | description |
|---|---|---|
| opts | any |
start(opts: any?) → void
Configure (optional) and start the director on this engine. Safe to call more than once.
| arg | type | description |
|---|---|---|
| opts | any? |
config( ) → any
The live configuration (a copy).
styles( ) → any
Every style name: `{ pacing = {...}, looks = {...}, palettes = {...} }`.
pacing( ) → any return Styles
look( ) → any return Styles
palette( ) → any return Styles
remember(kind: string, amount: number) → void
| arg | type | description |
|---|---|---|
| kind | string | |
| amount | number |
stimulus(kind: string, amount: number?, opts: any?) → void
Something happened to this player. `kind` is one of noise, gunshot, slam, scream, nearMiss, scare, sighting, hurt, darkness, battery, torchFail, calm, relief, custom (unknown kinds count as custom). `amount` 0..1 scales it (default 1). opts: `at` (a position: further away weighs less, out to `radius`, default 25 m), `weight` (override the kind's weight). Raises (or, for calm/relief, lowers) dread at once and resets the silence clock.
| arg | type | description |
|---|---|---|
| kind | string | |
| amount | number? | |
| opts | any? |
setThreat(v: number, opts: any?) → void
How close the threat is: a distance in metres (> 1; 3 m or less is full, 25 m or more is none) or a 0..1 amount. 0 clears it. Held for 5 s unless set again (a monster kit sets it every frame or on change); pass opts.hold to hold longer.
| arg | type | description |
|---|---|---|
| v | number | |
| opts | any? |
setSafe(on: boolean) → void
Enter or leave a safe room. While safe, dread does not build and drains quickly, scares are refused, and the music falls quiet. Fires `safe{on}`.
| arg | type | description |
|---|---|---|
| on | boolean |
setHiding(on: boolean) → void
The player is hiding (in a locker, under a desk): breathing becomes audible and dread holds instead of easing.
| arg | type | description |
|---|---|---|
| on | boolean |
setTorch(on: boolean) → void
The player's torch is on or off (darkness builds faster with it off).
| arg | type | description |
|---|---|---|
| on | boolean |
setBattery(charge: number) → void
The torch battery 0..1 (below 0.25 builds unease). flashlightKit's batteryLow can call this.
| arg | type | description |
|---|---|---|
| charge | number |
setHealth(fraction: number) → void
The player's health 0..1, when no SecondWind Vitals is on the player to read it from.
| arg | type | description |
|---|---|---|
| fraction | number |
setLight(v: number?) → void
How lit the player is 0..1, to override the automatic read (aiKit's AI.lightAt). nil hands back to the automatic read.
| arg | type | description |
|---|---|---|
| v | number? |
set(v: number) → void
Force the level (tests, cutscenes, a checkpoint restore).
| arg | type | description |
|---|---|---|
| v | number |
reset( ) → void
Clear everything back to calm (a new run, a respawn).
get( ) → number
The dread level, 0..1.
band( ) → string
The band the level is in: calm, uneasy, tense, terror or panic.
state( ) → any
Everything the director knows right now (a copy): level, band, threat, light, safe, hiding, torchOn, health, battery, silence (seconds since the last event), scares, breatherLeft, nextScareIn, budget, recent stimuli, pacing, look, palette.
suggestScare( ) → number
The largest scare intensity (0..5) the pacing allows right now: 0 while safe, inside the minimum gap or a breather; otherwise a budget that ramps with play time, capped while dread is already very high.
canScare(intensity: number?) → boolean
Whether a scare of this intensity (1..5) may play now. scaresKit's gate.
| arg | type | description |
|---|---|---|
| intensity | number? |
scared(intensity: number?, opts: any?) → void
Report that a scare played (intensity 1..5): starts the minimum gap and a breather scaled by its intensity, raises dread, plays a stinger for big ones, and fires `scare{intensity}`.
| arg | type | description |
|---|---|---|
| intensity | number? | |
| opts | any? |
_vec(v: any) → vector
| arg | type | description |
|---|---|---|
| v | any |
_localAvatar( ) → any
_herePos( ) → vector
_s( ) → any return S end
_cfg( ) → any return cfg end
softLinks( ) → void
sense(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
tick(dt: number) → void
Advance the director by dt seconds (the host calls this every frame).
| arg | type | description |
|---|---|---|
| dt | number |
debug(on: boolean?) → void
Show or hide the on-screen dread readout (bar, number, band, recent stimuli). Also toggled by the debug key (F3 by default). With no argument, flips it.
| arg | type | description |
|---|---|---|
| on | boolean? |
isDebug( ) → boolean
_reset( ) → void
Tests only: wipe state and listeners.
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.