# horrorKit
Everything a first-person survival-horror game needs, as one install: a light that throws real shadows and a battery you worry about, placed lights that flicker and die on cue, scripted events and a library of scares, a tension director that paces them and drives the music, heartbeat and screen feel, monsters that hunt you by sound and by your light, notes and tapes that tell the story, and the survival loop around them (scarce weapons, doors and keycards, supplies, safe rooms, save terminals and a HUD). Every style is one field. Built for multiplayer: two players see the same doors, monsters, lights and scares, and each has their own light, dread and HUD.
Version **1.0.21** (`Horror.VERSION`). horrorKit declares every package below in its `package.yaml`, so installing it brings each one at the version listed.
## What it installs
horrorKit is the umbrella. Each horror part is also its own package you can install alone:
| package | version | what |
|---|---|---|
| **flashlightKit** (was torchKit) | 1.0.4 | 12 handheld lights (classic torch, penlight, lantern, head lamp, phone, flare, glow stick, candle, dynamo, UV, camera flash, lighter), 11 battery types, recharge and swap, failures the story triggers |
| **eerieLightsKit** (was flickerKit) | 1.0.6 | 16 placed-light behaviours (dying fluorescent, guttering candle, swinging bulb, emergency red, alarm beacon, strobe, lightning, sparking, brown-out, sodium warm-up, TV glow, neon...), short-outs, power circuits, shadow-only figures |
| **scriptedEventsKit** (was cueKit) | 1.0.4 | triggers (area, look-at, pickup, door/interact, timer, chain, dread, event) playing ordered beats; once or repeating; remembered across death; host-decided for everyone |
| **scaresKit** (was scareKit) | 1.0.4 | 26 original scares rated 1 to 5 (knock, whisper, footsteps behind, shape crossing, lights die and it's closer, vent burst, door slam, power failure, body drop, chase sting...) |
| **tensionKit** (was dreadKit) | 1.0.4 | the tension director: 6 pacing styles, 6 screen looks, 5 audio palettes, music/ambience/heartbeat/breathing, a dread readout (F3) |
| **loreKit** | 1.0.6 | notes, memos, terminals, tapes with voice and subtitles, graffiti, data pads, photos, and a journal |
| **stalkerKit** | 1.0.10 | monsters on aiKit: pursuer, shambler, lurker, light-shy, blind hunter |
| **bulkheadKit** | 1.0.3 | rooms, corridors and props for station and ship interiors, used by the showcase room |
And the published kits it stands on, each declared with the version it is built and tested against:
| package | version | used for |
|---|---|---|
| aiKit | 1.4.0 | monster brains and senses, including carried lights (a flashlight gives you away) |
| navKit | 1.5.8 | monster movement |
| interactKit | 1.6.8 | doors, locks, keycards, switches, every use prompt |
| inventoryKit | 1.0.27 | the spare-battery bag and item strip |
| saveKit | 1.3.21 | checkpoints at save terminals, the lore journal |
| weaponsKit | 1.3.3 | the revolver, coach gun and flare pistol |
| SecondWind | 1.4.8 | health, first aid, death |
| Lifeline | 1.0.4 | respawn points |
| soundstage | 2.1.3 | music driven by the tension director |
| juiceKit | 1.2.12 | camera shake, sway and tremor |
| controlsKit | 1.4.9 | rebinding, prompts and touch buttons |
Not a dependency: **stealthKit**. The HUD has a light and noise element (`HorrorHUD.showStealth`) that draws whatever source a game hands it with `HUD.setSource("stealth", fn)`; the `horrorStealthLink` package passes stealthKit's readout there (place one `horrorStealthLink.StealthReadout`; this world's Brinefall scene does). Installing horrorStealthLink brings stealthKit with it; installing horrorKit alone does not. horrorKit itself never requires stealthKit, so installing horrorKit does not bring it.
Not a dependency either: **menusKit** (horrorKit draws no menu; Brinefall's ending screen uses it and declares it).
## First example
In a scene's `build.luau`, with a first-person player already set up:
```lua
local director = entity.spawn("HorrorDirector")
director.component.add("horrorKit.HorrorDirector", {
pacing = "survivalClassic", look = "grain70s", palette = "deepSea",
hud = "classic", torch = "classic", loadout = "revolver",
})
```
Press Play: every player carries a torch (F toggles, V shakes it back to life, B swaps a battery) and a six-shot revolver with a far-too-slow reload; dread builds in the dark and drives the music, heartbeat, breathing and screen; F3 shows the dread readout.
## The one-field styles
| field | values |
|---|---|
| `pacing` | slowBurn, rollercoaster, relentless, quietDread, survivalClassic, arcade |
| `look` | clean, grain70s, vhs, coldMonitor, sickly, bleachBypass |
| `palette` | industrial, deepSea, organic, synth, classic |
| `hud` | bare, minimal, classic, scifi, vhs, diegetic |
| `torch` | any flashlightKit style |
| `loadout` | revolver, coachgun, flaregun (comma separated) |
Per object: `LightBehavior.style`, `Stalker.kind`, `Lore.style`, `Scare.scare`, `interactKit.Door.look`.
## Components
| component | what |
|---|---|
| `HorrorDirector` | one per scene: the styles above; equips each player; runs the wiring |
| `HorrorHUD` | the HUD (the director adds it from its `hud` field) |
| `SafeRoom` | a box where dread pauses and drains, scares hold and monsters break off (`extents`, `label`, `blockMonsters`) |
| `SaveTerminal` | use it to save a checkpoint (saveKit), move your respawn here and recharge your light |
| `Supply` | `kind` = ammo, firstAid, bandage, battery; `amount`; per player by default |
## The wiring (`require("~horrorKit.api")`)
Loading `horrorKit.api` hands the optional kits to the horror kits that use them (`tensionKit.links`, `scriptedEventsKit.links`, `scaresKit.links`, `loreKit.links`): aiKit, SecondWind, soundstage, juiceKit, interactKit, inventoryKit and saveKit. The horror kits never require those by name, so each of them installs on its own with nothing extra; in a horrorKit game everything is linked with no call of yours (`Horror.linkKits()` repeats it).
`Horror.setup(opts)` (the director calls it) connects, on each player's own engine:
- the torch's visibility and beam -> the monsters (stalkerKit, through aiKit's carried light); its click -> a noise they hear;
- gunshots, doors and torch clicks -> monster noises and dread stimuli;
- monster threat, sightings and attacks, low battery and low health -> dread;
- scares -> asking the director first and reporting back (pacing);
- safe rooms -> dread pause and the HUD marker.
Also: `Horror.setSafe(on)`, `Horror.isSafe()`, `Horror.message(text, seconds)`, `Horror.objective(text)`, `Horror.localBody()`, `Horror.teardown()`, and every part as `Horror.Torch`, `Horror.Dread`, `Horror.Stalkers`, `Horror.Scares`, `Horror.Cues`, `Horror.Lore`, `Horror.Weapons`, `Horror.Interact`, `Horror.Arms`, `Horror.HUD`.
**Weapons** (`horrorKit.weapons`, on weaponsKit): `revolver` (6 rounds, 4.2 s reload), `coachgun` (2 shells, 5 s reload), `flaregun` (one flare that lights and burns). `Arms.give(body, "revolver,coachgun")`, `Arms.addAmmo(body, n)`.
## HUD
Six styles, one field (`hud` on the director, or `HorrorHUD.style`): `bare`, `minimal`, `classic`, `scifi`, `vhs`, `diegetic`. Health, ammo in the gun and spare, light battery, keys and keycards, items, a damage vignette, pickup and objective lines, the safe-room marker and an optional dread hint. Per player; scales for desktop, browser, tablet and phone and keeps clear of the touch controls.
| style | look |
|---|---|
| `bare` | nothing but the damage vignette, the low-health pulse and transient lines (objective, safe room, "Out of ammo", "Battery low" arrive as messages) |
| `minimal` | tiny monospace corner text that fades to a ghost after 3.5 s without change and comes back when something changes; warnings stay lit |
| `classic` | survival-horror status panel: an ECG line whose colour, rhythm and sweep speed follow FINE / CAUTION / DANGER, battery cells, a big ammo count, key and keycard icons |
| `scifi` | helmet visor: corner brackets, scanline wash, a vitals arc, PWR cell bar, a round counter with magazine ticks, ACCESS chips |
| `vhs` | camcorder OSD: blinking REC dot, HP level meter, the torch battery as the camera battery, CNT counter and tape time, date, tracking-noise bands that thicken and redden when hurt |
| `diegetic` | a leather wrist strap with two analogue dials (LAMP charge and PULSE, needles with red zones) and a clipped paper note: the objective as a to-do, rounds as hand-drawn tally marks, spare count, key tags |
Put `HorrorHUD` on any entity (the director adds one), or drive it from code with `local HUD = require("~horrorKit.hud")`:
| call | does |
|---|---|
| `HUD.setStyle(name)` / `HUD.style()` / `HUD.styles()` | switch the look; list them with descriptions |
| `HUD.setPalette(style?, overrides?)` / `HUD.palette(style?)` | recolour a look without replacing it (style defaults to the current one; `nil` overrides restores its defaults). Keys: `font`, `color`, `bg`, `shadow`, `accent`, `size`, `upper`, `radius`, `border`; the `classic` look also reads `accent` (objective bar), `objectiveLabel`, `objectiveText`, `battery`, `batteryLow`, `batteryDead`, `batteryDim` and `batteryOrientation` (`"horizontal"` default, or `"vertical"` for upright cells filling from the bottom). `HUD.PALETTES` holds them all |
| `HUD.message(text, seconds?, { color }?)` | a transient line (up to three stack; the same line again restarts it) |
| `HUD.objective(text?)` | the current objective (nil or "" clears) |
| `HUD.setSafe(on, label?)` | the safe-room / save badge |
| `HUD.setElement(name, on)` / `HUD.setElements(t)` | health, ammo, light, keys, items, vignette, messages, objective, safe, dread, stealth |
| `HUD.setVisible(on)`, `HUD.setScale(k)` | hide for cutscenes and menus; size multiplier |
| `HUD.setTarget(body?)` | show another body's data (spectating) |
| `HUD.setSource(kind, fn?)` | replace a data source (health, ammo, light, keys, items) for a game that keeps its own; `stealth` has no source until a game sets one (`fn` returns `{ light, class, threshold, noise, reach }`) |
| `HUD.state()` | what it shows now (tests) |
Data comes through soft links, so a missing kit just leaves its element empty: SecondWind (`HK.state`), weaponsKit (the local `Weapon`'s synced `ammo`/`reserve`/`reloading`), flashlightKit (`Torch.charge`/`switchedOn`/`spares`, and its `batteryLow`/`batteryDead`/`swapped` events), interactKit (the player's keys and keycards), inventoryKit (the hotbar) and tensionKit (`get`/`band`). While it runs it hides weaponsKit's ammo panel, flashlightKit's meter, interactKit's carried strip and Lifeline's own player bar (and Lifeline's vignette), and gives them back when it stops (`hideKitHuds = false` keeps them). It samples ten times a second and rebuilds only when what it shows changes (0 rebuilds a second while nothing changes); pulses, blinks, sweeps and noise are engine-run CSS animations. On a touch screen it moves out of the lower corners (movement stick, action buttons): sideways into a left column and beside the corner buttons, upright into one column down the left.
## Showcase room
One call builds a compact, dark room that shows the whole kit working: three placed lights, flashlight pedestals (`TorchStand`), a scare on an area trigger, a note, a safe corner with a save terminal, and a monster pen (`MonsterPen` keeps the monster in). Copy it into your own world to see the kit before you build with it.
```lua
local Showcase = require("horrorKit.showcase")
function content()
-- your scene and first-person player (Camera environment = "isolated"), with the new-world
-- template's `lighting` entity deleted: its sky lights the room even through an isolated camera
Showcase.build(nil, { at = { 40, 0, 0 } })
end
```
Options: `at`, `theme`, `director`, `monster`, `navMap`, `scare`, `stands`, `labels`, `name` (see `showcase.module/README.md`). `Showcase.label(parent, name, pos, yaw, title, opts)` draws a readable world-space label.
## Kit gallery
The horrorKit world also has a walkable gallery scene (`scenes.gallery`; a console in Brinefall's dive bay opens it, a button in its hub goes back): all 12 flashlight styles on pedestals, every battery type and failure mode on buttons, all 16 placed light styles, every light state with a circuit, a Silhouette and an Apparition, five monster pens and all 26 scares in booths that replay, each with a label. From code: `layers.load("scenes.gallery")`.
## Guides
- **How to make a horror game: light a dark room, build a scare, tune the tension and add a monster that hunts the player** (`horrorKit.package/how-to-make-a-horror-game-light-a-dark-room-build-a-scare-tune-tension-add-a-monster`)
- **Build a small horror level from an empty world, step by step** (`horrorKit.package/build-a-small-horror-level-from-an-empty-world`)
Open them with the `guides` tool or the Docs panel. Each package also carries its own guide.
## Example
**Brinefall Station** (the `brinefall` package in the horrorKit world): a 10–15 minute level in a flooded deep-sea research station, built from these parts and bulkheadKit.
## 1.0.21
On saveKit 1.3.21 (from 1.3.20) and controlsKit 1.4.9 (from 1.4.7): saveKit 1.3.21 is built against controlsKit 1.4.9 and menusKit 1.4.5, which no longer need the engine's deleted zui UI library; this world now states saveKit with its package.yaml. The Hold Your Breath world's entrypoint loads its dark theme through `ui.loadTheme` instead of requiring the deleted zui theme module, so the world loads and pushes on the current engine. No horrorKit code changes.
## 1.0.20
Published by a push that timed out with a 503 before the controlsKit pin was moved: it states saveKit 1.3.21 and still states controlsKit 1.4.7, which saveKit 1.3.21 does not bring. Use 1.0.21.
## 1.0.19
horrorKit's own dependency copy of barsKit carries barsKit's Showcase component in full again (661 lines). 1.0.18 bumped the showcase packages' versions but the restore itself did not reach main in that release, so its barsKit copy still shipped the empty file 1.0.17 had (found while releasing Low Water). No other change.
## 1.0.18
On scaresKit 1.0.5 (which states scriptedEventsKit 1.0.4) and saveKit 1.3.20. No horrorKit code changes.
## 1.0.17
On stalkerKit 1.0.10: a Stalker whose kind the game defines after it woke (a joining player's engine) waits for the kind instead of failing, so a second player's creature no longer loses its brain. No horrorKit code changes.
## 1.0.16
`Horror.clearRespawn(body?)` forgets which save terminal brings a player back, so a New Game respawns them at the level start until they use a terminal again (before, the terminal from the finished game stayed their respawn). HUD palettes take `objectiveFont`, the classic objective text's font family (default `ptserif`, unchanged), so a game can match its menu type. On saveKit 1.3.20 (`Save.clearCheckpoint()`).
## 1.0.15
SaveTerminal fix to 1.0.14: it wrote and read the respawn attribute by indexing the body's attribute proxy, which is sealed, so using a terminal only warned "respawn not moved" and the picker never saw a choice. It now goes through `attribute.set` / `attribute.get`. Verified in play with two terminals.
## 1.0.14
HUD palettes: `HUD.setPalette(style?, overrides?)` and `HUD.palette(style?)` recolour a look without replacing it; the `classic` look's objective bar (`accent`), objective label and text, and its battery cells (`battery`, `batteryLow`, `batteryDead`, `batteryDim`, `batteryOrientation` = `"horizontal"` or `"vertical"`) are no longer hardcoded. Defaults unchanged. SaveTerminal now really moves your respawn: every terminal's Lifeline spawn point starts switched off, using a terminal marks it on your body (attribute `horrorKitRespawnTerminal`), and a spawn picker brings each player back at the terminal they used last (before any save, Lifeline's own choice: the level's PlayerSpawn or any SpawnPoint the game placed). Before, every terminal's point was live from play start and Lifeline picked one at random. On loreKit 1.0.6 (subtitles setting), bulkheadKit 1.0.3 (surfaces no longer black under an isolated camera, `B.collect` for batching), flashlightKit 1.0.4 (torch follows the carrier when the main camera is elsewhere), stalkerKit 1.0.9 (`drowned` body, `appearAt` cancels a retreat) and scriptedEventsKit 1.0.4 (`call` beat takes `fn`). New HUD palette test.
## 1.0.13
On eerieLightsKit 1.0.6. The guide *Build a small horror level from an empty world* now turns the first-person rig to face up the corridor (`rig.localRotation = { 0, 1, 0, 0 }`; the camera starts from the rig's own pose) and lights the corridor brightly enough to see (tubeA 18, tubeB 14, cabinBulb 8, medTube 25). Contributed in pull request #2.
## 1.0.12
On eerieLightsKit 1.0.5 and stalkerKit 1.0.8. No code changes.
## 1.0.11
On eerieLightsKit 1.0.4 and stalkerKit 1.0.7. No code changes.
## 1.0.10
README only: the table of the kits it installs lists the versions 1.0.9 brings (eerieLightsKit 1.0.3, scriptedEventsKit 1.0.3, scaresKit 1.0.4, tensionKit 1.0.4); the 1.0.9 README still showed the earlier ones. No code changes.
## 1.0.9
While the horror HUD is up it also hides saveKit's own level and XP bar (and puts it back when it stops), so no "LV 1, 30 / 100 XP" bar appears in a horror game or pushes the condition and weapon panels. On flashlightKit 1.0.3, eerieLightsKit 1.0.3, scriptedEventsKit 1.0.3, scaresKit 1.0.4, tensionKit 1.0.4, loreKit 1.0.5 and stalkerKit 1.0.6.
## 1.0.8
On SecondWind 1.4.8 and stalkerKit 1.0.5, the SecondWind stealthKit 1.0.22 brings, so adding horrorStealthLink leaves one SecondWind in the world. No code changes; hudTests 11/11.
## 1.0.7
README: the stealth readout bridge, horrorStealthLink, installs into a fresh world now (stealthKit 1.0.20), so the README no longer calls it blocked. On SecondWind 1.4.7 (the newest SecondWind release) and stalkerKit 1.0.4. No code changes.
## 1.0.6
README: the stealth readout bridge says plainly that its fresh install is blocked upstream for now.
## 1.0.5
On loreKit 1.0.4 (its reader test no longer leaves engine errors). The stealth readout bridge, horrorStealthLink 1.0.2, now brings stealthKit 1.0.17.
## 1.0.4
Brings the fixed kits from the fresh-world check: eerieLightsKit 1.0.2, scaresKit 1.0.3, tensionKit 1.0.3, stalkerKit 1.0.3 (monster surfaces), loreKit 1.0.3, bulkheadKit 1.0.2.
## 1.0.3
- Depends only on the packages its own code uses: menusKit is no longer declared; SecondWind is declared at the release its references reach.
- `horrorKit.api` links the optional kits into tensionKit 1.0.2, scriptedEventsKit 1.0.2, scaresKit 1.0.2 and loreKit 1.0.2, which no longer require them by name (so none of them drags another kit into an install).
- The stealth readout link moved out of Brinefall into the new `horrorStealthLink` package.
## 1.0.2
- Installs into an empty world again: 1.0.1 recorded stealthKit 1.0.15 as a dependency (the HUD required its readout by name), and that release does not install into a fresh world, so `zeromind installAsset` refused horrorKit 1.0.1 everywhere. The HUD's stealth element now reads only a source the game sets (`HUD.setSource("stealth", fn)`).
- Darkness: the showcase snippet and the guides now say to delete the new-world template's `lighting` entity. Its sky lit a closed room to mean 37/255 with every light and the torch off, through an isolated camera; deleted, the same room reads 0.5/255.
- Cheaper frame: HorrorDirector re-asserts the own-body hider and the single touch Menu button 10 times a second instead of every frame (each pass walked the body's descendants and read the main camera).
## Multiplayer
Shared and host-decided: doors, keycards and locks (interactKit), placed lights (eerieLightsKit), cues and scares (scriptedEventsKit), monsters (stalkerKit on aiKit). Per player: torch and battery, dread and everything it drives, HUD, journal, supplies.
## Known limits
- Monster bodies are re-proportioned, re-skinned built-in humanoids with attached parts, not sculpted creatures (mesh generation was unavailable when this was made).
- The torch toggle (F) is also controlsKit's second interact key in its fps scheme; E stays interact.
# api
stalkerKit's one interface: local Stalkers = require("stalkerKit.api"). Spawn monsters and lairs, script encounters (sendTo, retreat, appearAt, holdHidden, setKind, setActive), wire noises (hearNoise) and torches (setPlayerLight), read threatFor(player) for a tension director, list/info/nearest, tune kinds, and listen to events (state, noticed, lost, attacked, hurt, retreated, appeared, died, noise).
# scriptedEventsKit.net
The multiplayer plumbing: who is host, who may write an entity (canWrite), the session clock, and the cue channels (cue:req, cue:run, cue:flag, cue:reset, cue:hello, cue:snap). Used by scriptedEventsKit.api and scriptedEventsKit.beats; tests drive it with _deliver and _tap.
# horrorKit.api
The wiring of the horror kit: `setup(opts)` connects flashlightKit, eerieLightsKit, scriptedEventsKit, scaresKit, tensionKit, loreKit, stalkerKit, weaponsKit and interactKit on each player's engine (light and noise to the monsters, threat and stimuli to dread, scares gated by dread pacing); `tick(dt)`, `setSafe`, `isSafe`, `message`, `objective`, `localBody`, `isMine`, `teardown`; and every part as a field (`Horror.Torch`, `Horror.Dread`, ...). Called by the HorrorDirector component and by game scripts.
# api
`loreKit.api` (`require("~loreKit.api")`) is loreKit's public surface: define entries (`define`, `get`, `ids`), open and close the reader (`open(id, { style })`, `close`, `current`), the per-player journal (`find`, `markRead`, `journal`, `unread`, `openJournal`, `toggleJournal`, `resetJournal`, `loadJournal` from saveKit), the style list (`STYLES`, `STYLE_INFO`) and events (`on("read"|"found"|"opened"|"closed"|"journal")`). Game code, the Lore component and horrorKit call it.
# brinefall.story
The eight original lore entries of Brinefall Station as loreKit data; `define()` registers them. Called by brinefall.script.
# scriptedEventsKit.api
The front door of scriptedEventsKit: define cues (trigger + ordered beats + rules), fire them, read the ledger, set flags, listen to events and extend the kit with your own beats and triggers. `local Cues = require("~scriptedEventsKit.api")`. Called by level scripts, scene entrypoints, the Cue component and scaresKit. See the package README for every trigger, beat and event.
# scaresKit.api
The scare library's front door: place a scare with one call (props + cue), list and pick scares by intensity and tags, install a director gate, link tensionKit, make director-chosen slots, and hear every scare that lands. Also registers scaresKit's own scriptedEventsKit beats (jitter, swing, showTree, hideTree, soundPath, behind, waitUnseen, shadow, interact). `local Scares = require("~scaresKit.api")`.
# stalkerKit 1.0.2
Horror monsters that hunt the player. Put a `Stalker` on a character, pick a **kind** with one field, and it listens, follows your torch light, stalks you out of sight, hunts where it heard you, searches where it lost you, chases, attacks, and slips back into a vent when it is hurt or caught in your light too long, to come back later. Five kinds ship (pursuer, shambler, lurker, light-shy, blind hunter); each is plain data a designer tunes without code.
stalkerKit is built on **aiKit** (brains, senses, memory), **navKit** (movement) and **SecondWind** (health and damage). That means **weaponsKit** weapons hurt the monsters with no extra wiring, and every aiKit character hears the same noises.
## Install
Install `stalkerKit.package` from ZeroMind (search "stalkerKit" or "monster that hunts the player by sound and light"). It needs aiKit 1.4.0 or later in the world (aiKit brings navKit, SecondWind, Lifeline and MatchFlow); 1.4.0 is the release that adds carried lights (`AI.setCarriedLight`), which is how a torch gives the player away.
## First example
In code that runs in play on the host, once the level's colliders exist, with a navKit map baked over the floor (`require("~navKit.api").bake({ kind = "grid" })`, a frame or more after the walls are spawned; see Known limits):
```lua
local Stalkers = require("stalkerKit.api")
-- a vent the pursuer can slip into (stand it on the floor in front of the opening)
Stalkers.addLair({ -56, 0, -404 })
Stalkers.addLair({ -4, 0, -456 })
-- the hunter and a drowned diver
local pursuer = Stalkers.spawn("pursuer", { -25, 0, -412 })
local diver = Stalkers.spawn("shambler", { -20, 0, -430 })
-- your game hands over its own: here a stand-in player body, its camera's forward and a shot
local playerBody = entity.spawn("playerBody"); playerBody.position = vector.create(-25, 0, -420)
local cameraForward = vector.create(0, 0, -1)
local shooterBody, shotPosition = playerBody, vector.create(-25, 1.5, -420)
-- weapon fire, doors and torch clicks give the player away
Stalkers.hearNoise(shotPosition, "gunshot", shooterBody)
-- a torch kit says how visible a player is (0 dark .. 1 torch on) and where the beam points
Stalkers.setPlayerLight(playerBody, 1, cameraForward)
-- a tension director reads how close the danger is
local danger = Stalkers.threatFor(playerBody) -- 0..1
Stalkers.on("noticed", function(e) print(e.entity.name, "is after", e.target.name) end)
```
Or place it by hand: a synced entity with `stalkerKit.Stalker { kind = "pursuer" }` (it adds the aiKit `Brain` itself), and `stalkerKit.StalkerLair` on the entities in front of your vents.
## Kinds
| kind | look | senses | what it does | dies? |
|---|---|---|---|---|
| `pursuer` | tall, gaunt, too-long limbs and claws, pale wet skin, barnacle crusts, an eyeless elongated skull with a slit of needle teeth | sees only lit things (beyond 4.5 m), 24 m, 140°; hears 1.7× as far; notices a torch beam in its face from 16 m and a lit torch inside its cone from 36 m | the main hunter: hears shots, running, doors, torch clicks and thrown things; stalks out of sight at 8-14 m for up to 9 s, commits when you come close, shine your torch on it or it has watched long enough; chases, attacks (28 dmg); hunts and searches the last-known spot; after 5 s lit, 22% health lost in 6 s or 22 s of chasing it screeches and runs to the nearest vent, crawls in, heals for 16-30 s and crawls out of the vent nearest a player | no: at 20% health it retreats and heals |
| `shambler` | a drowned diver: bloated, in a rotting canvas suit, cracked brass helmet with a swollen face behind the porthole, lead boots, kelp | 9 m sight, poor hearing (0.8×), remembers for 40 s | slow (0.85 / 1.55 m/s), relentless (gives up after 12 s unseen), grabs and bites (34 dmg, slow), 360 HP, shrugs off small hits | yes |
| `lurker` | a darker, crouched pursuer thick with barnacles | 16 m, all round | waits motionless where you put it; moves only while no player is looking at it (freezes in your view); lunges from 3 m with a hiss; after a short chase melts back into a lair or the dark | yes |
| `lightshy` | pale pink skin with glowing blue spots on its skull | 18 m, notices beams | circles at 5-9 m at the edge of your light; a beam or strong light on it for 1.2 s makes it recoil to the nearest dark; strikes the moment you stand in darkness | yes |
| `blind` | grey-green, eyeless, a huge barnacle-crowned skull | hearing only, 2.2× (a walking footstep from 11 m) | goes where it heard; walk slowly (silent), throw something, or stand still | yes |
### Body styles (`stalker.body`, one field)
Every kind's look is its `stalker.body` knob, so any kind can wear any body: `pursuer`, `shambler`, `lurker`, `lightshy`, `blind`, and `drowned`.
`drowned` (new in 1.0.9): a tall (2.55 m), gaunt, long-limbed, hunched figure draped in river weed and dripping silt. Dark olive-brown silt skin that stays matte under a torch (roughness 0.88, metallic 0, almost no clearcoat), a dark elongated skull, long dark claws, no barnacles and nothing that glows. About 40 strands of weed hang from the head, shoulders, elbows, hands, back, hips and thighs; each hangs from gravity whatever the pose, bends in two segments and sways in `Body.update` (more while it moves), and a pool of 10 silt drops falls from the strand tips and is reused (parked while the body is hidden). Use it on any kind:
```lua
Stalkers.tuneKind("pursuer", { stalker = { body = "drowned" } }) -- every pursuer
Stalkers.defineKind("riverman", { base = "pursuer", stalker = { body = "drowned", sounds = "shambler" } })
```
Every kind is an aiKit preset (`stalker.<kind>`) plus a `stalker` table of knobs. Change them for the whole game:
```lua
local Stalkers = require("stalkerKit.api")
Stalkers.tuneKind("pursuer", { stalker = { stalkTime = 15, hideTime = { 40, 60 } }, preset = { move = { run = 5.6 } } })
Stalkers.defineKind("hound", { base = "pursuer", label = "Hound", preset = { move = { run = 7 } }, stalker = { stalk = false } })
```
### Knobs (`stalker` table)
| knob | pursuer | meaning |
|---|---|---|
| `drawnToLight` | 1 | 0..1: a lit torch inside its eyes' cone is a lead out to 36 m × this |
| `lightShy` | 0 | light level where it stands that it cannot bear (0 = never) |
| `litTolerance` | 5 | seconds in a beam / strong light before it breaks off (0 = never) |
| `attackOnlyInDark` | false | will not close in while the prey stands in light |
| `stalk`, `stalkRange`, `stalkTime`, `commitRange` | true, {8,14}, 9, 5 | keep its distance out of sight before committing |
| `huntRun` | true | runs to loud leads (gunshot, door, shout) |
| `chaseTimeout` | 22 | seconds of chase before it slips away (0 = never) |
| `searchTime`, `vanishAfterSearch` | 14, 0.5 | how long it searches; the chance it then slips into a lair |
| `retreats`, `hurtRetreat` | true, 0.22 | breaks off after losing this share of health within 6 s |
| `dies`, `floor` | false, 0.2 | false: never drops under `floor` health; retreats and heals instead |
| `hideTime`, `returnNear` | {16,30}, true | seconds in the lair; come out of the lair nearest a player |
| `lurk`, `freezeWhenWatched`, `springRange` | false, false, 3 | ambusher behaviour |
| `flinch`, `staggerAt` | 0.3, 30 | seconds a hit stops it; damage in one hit that staggers it twice as long |
| `grab` | false | slow grab-and-bite attack |
| `breathEvery`, `screechOnNotice` | {4,7}, true | feel |
| `body`, `sounds` | pursuer | which body and sound set it uses |
## API (`local Stalkers = require("stalkerKit.api")`)
| call | what it does |
|---|---|
| `Stalkers.spawn(kind, at, opts?) -> entity` | Spawn a synced stalker (`opts`: name, yaw, lairGroup, route, active). |
| `Stalkers.addLair(at, opts?) -> entity` | A vent / dark hole at a position, or on an entity (`opts`: group, kind = "vent" or "dark", yaw). |
| `Stalkers.sendTo(e, pos, { run })` | Send it to look at a spot. |
| `Stalkers.retreat(e)` | Break off now and slip into a lair. |
| `Stalkers.appearAt(e, pos, { face })` | It crawls out at a spot, then hunts toward the nearest player. Cancels a retreat still under way and releases a `holdHidden`. Orders sent in the same moment are all seen, in order; the last that changes what it does wins. |
| `Stalkers.holdHidden(e, on)` | Keep it in its lair until released. |
| `Stalkers.setKind(e, kind)`, `Stalkers.setActive(e, on)` | Switch kind; switch its brain off/on. |
| `Stalkers.hearNoise(pos, loudness, source?, kind?)` | A noise: metres or a name (`gunshot` 35, `slam` 22, `throw` 16, `door` 14, `run` 11, `impact` 10, `click`/`torch` 6, `footstep` 5). `source` = who gives themselves away. Goes through aiKit's noise bus. |
| `Stalkers.setPlayerLight(player, level, beamDir?, { range, cone })` | A torch kit reports a player's light (0..1) and beam; call it on the player's own peer. |
| `Stalkers.playerLight(player)` | The light as the monsters know it. |
| `Stalkers.threatFor(player) -> 0..1` | Danger for a tension director: nearest stalkers, what they do, whether they are after this player. Every peer. |
| `Stalkers.list()`, `Stalkers.info(e)`, `Stalkers.nearest(pos, { visible })` | What is out there. |
| `Stalkers.kindNames()`, `kind(name)`, `defineKind`, `tuneKind` | The kinds as data. |
| `Stalkers.on(event, fn) -> connection` | Events (below); call the connection or `:Disconnect()` to stop. |
## Events
| event | payload | fires on |
|---|---|---|
| `state` | `entity, state, from, detail`, state is `idle`, `stalk`, `hunt`, `search`, `chase`, `retreat` or `attack`; `detail` is the brain's own state (lurk, creep, recoil, vent, hidden, appear...) | every peer |
| `noticed` | `entity, target` | every peer |
| `lost` | `entity, target` | every peer |
| `attacked` | `entity, target, kind` (attack, grab) | every peer |
| `hurt` | `entity, amount, by` | the peer running it |
| `retreated` | `entity, lair` | the peer running it |
| `appeared` | `entity` | the peer running it |
| `died` | `entity, by` | the peer running it |
| `noise` | `position, radius, kind, source` | the peer that called hearNoise |
| `*` | `{ event, data }` | all of the above |
## Fighting them
Their health is SecondWind's, so weaponsKit's hitscan, projectiles and melee hit them (weaponsKit hits collider-less characters as a capsule; the Stalker sizes it to the creature: 2.3 m for the pursuer, 0.5 m wide for the shambler). A hit flinches them; one of 30+ damage staggers. The pursuer cannot be killed by default (`dies = false`): it screeches and retreats to heal, so ammo buys time, not safety. The shambler dies after about 360 damage. **Ammo is the level's job**: keep it scarce (a handful of rounds per encounter) so running, hiding in the dark and turning the torch off stay the better answer.
## Multiplayer
The host (or the entity's owner) runs the brains through aiKit; every peer builds the same body from the synced `kind` and animates it from the synced pose and one-shot counter, and plays the sounds locally, so nothing but a few fields crosses the network. Any player can be hunted. Torch reports go from each player's peer to the host through aiKit's carried-light channel. Scripted orders (`sendTo`, `retreat`, `appearAt`, `holdHidden`) work from any peer.
## Performance
Each stalker is one aiKit brain (senses 10×/s, thinks 15×/s) plus a skinned body with ~60-110 small parts and an AnimGraph ticked in script. A pursuer is roughly one aiKit character plus one animated body; two or three on screen are fine on a tablet. Parts cast no shadows where they are small. Lower `AI.config.senseRate` / `thinkRate` for weaker devices.
## Known limits
- **Nothing reports your torch to the monsters unless something calls `setPlayerLight`.** horrorKit does it for flashlightKit's torch; with flashlightKit alone, call `Stalkers.setPlayerLight(body, Torch.visibility(nil))` on the player's own peer a few times a second.
- **Switching the torch off does not shake a pursuer that already has you.** Measured in an empty world, twice: standing still in the dark with no lead, it never found the player (idle at 18 to 21 m for 20 s); with the torch on it noticed at about 14 m, stalked and caught the player within about 10 s; switching the torch off then (during the chase, or after sending it to a lair) did not lose it: it went to where it last knew the player and, since it sees an unlit player inside `darkRange` (4.5 m), found them and kept attacking. Put distance, a door or a hiding place between you before you go dark.
- **Bodies are a re-proportioned stock rig.** Mesh generation was out of quota when this was built, so every creature is the engine's rigged humanoid stretched, re-skinned and dressed with procedural parts. A generated or imported rigged creature can replace it in `stalkerKit.body` (`Body.STYLES`).
- **A hidden stalker keeps its hit volume at its lair.** Shots into an empty vent can still hit it.
- **Lurker "watched" check uses where each player faces** (the torch report's beam when there is one, else the avatar's turn), not the exact camera.
- **Bake the navKit map after the level's colliders exist**: a grid map baked in the same frame the walls were spawned has no walkable cells and every stalker stands still ("unreachable").
- **Vents are entry points, not paths**: a stalker vanishes into one and comes out of another; it does not crawl through ducts.
## Tests
`tools.use("tests", "run", { suite = "stalkerKit" })` (edit mode): kinds and presets, the API, hearNoise reaching aiKit's bus, events, threatFor, and a play test where a pursuer hears a gunshot and goes to it.
## Version history
- **1.0.0**: First release: five kinds, the stalker brain, the Stalker and StalkerLair components, bodies, generated animations and sounds, the api with noise, light, threat and scripting hooks, a guide and a test suite.
## 1.0.2
README only: how to bake the navKit map in the first example; that the torch reaches the monsters only through `setPlayerLight` (horrorKit or your own code); what a pursuer does when you go dark mid-chase.
## 1.0.1
Bodies use lit materials, so a monster in a dark room is invisible until a light finds it. Overhead health bars are off by default (`healthBar` field). `setActive` reliably wakes and stills a monster. Declares aiKit 1.4.0 and its other dependencies with versions.
## 1.0.10
A Stalker whose kind the game defines after it woke now waits for that kind instead of failing. A joining player's engine receives the creature before the game's start code defines its own kinds, and the Stalker used to hand aiKit the unknown preset at once, which threw ("aiKit.addBrain: unknown preset 'stalker.<kind>'") and disabled the component for good on that player's side. Now its brain and body are built as soon as the kind exists (`Kinds.has(kind)` is new). New test: "waits for a kind defined after it woke". Found in Low Water's co-op.
## 1.0.9 (`stalker.body = "drowned"`): tall, gaunt, long-limbed and hunched, draped in swaying river weed, dripping silt, matte dark silt skin, nothing glows. `appearAt` now always cancels a retreat in progress: orders queue until the brain next thinks instead of the later one overwriting the earlier, a non-retreat order clears the retreat and frees the lair it was heading for, and `appearAt` releases a `holdHidden` (a game no longer needs to switch the brain off and on to bring it out). New test "appearAt cancels a retreat in progress".
## 1.0.8
Correction to 1.0.7: its wait for the sky light does not prevent the occasional 6 "camera texture not found" errors during the in-play test, so it is removed. Those errors come from the engine, not this kit: switching into play makes the sky light build six internal capture cameras, the test runner's leftover sweep removes them when the test ends, and the sky light later draws through the removed cameras (reported to ZeroMind). The tests pass either way; a plain install and play logs none. No changes outside the tests and README.
## 1.0.7
The tests leave no camera errors: the play test restarts the sky light, and each test now ends only once the sky light has finished its capture, so the runner's cleanup never removes capture cameras with a picture still queued. No changes outside the tests.
## 1.0.6
The tests remove everything each test (and the monsters it spawned) left behind and wait for previews a fresh install is drawing, so a passing run leaves no errors. The second README example requires the API itself and runs on its own. No changes outside the tests and README.
## 1.0.5
Declares SecondWind 1.4.8, the version stealthKit 1.0.22 brings, so a world with both kits runs one SecondWind. No code changes; stalkerKitTests 7/7 on 1.4.8.
## 1.0.4
Declares SecondWind 1.4.7, the newest SecondWind release, which is what an install beside stealthKit 1.0.20 places (it stated 1.4.8). No code changes; stalkerKitTests 7/7 on 1.4.7.
## 1.0.3
Bodies keep their surfaces again on the current engine: each part's roughness, clearcoat and glow (the pursuer's eyes and spots, the diver's porthole) went to `Model:setMaterialProperties`, which now writes the shared material and failed on the kit's runtime materials (hundreds of warnings, flat parts). Parts and skins now get materials of their own with those values, made once per look; no shared material is ever repainted. README: the first example defines the player body, camera forward and shot it uses.
# scriptedEventsKit
Named **scriptedEventsKit** since 1.0.1 (it was published as cueKit in 1.0.0). Search for either name.
**Scripted events for level designers: a trigger in the world plays an ordered list of beats.** Walk into the hall and the lights short out, a door swings shut two seconds later, a whisper, a flash, a subtitle. Write it as data, place it as a component, and it works the same for every player in a multiplayer world.
Version **1.0.4** (`Cues.VERSION`). The version, this README and `package.yaml` move together.
## Install
1. Install `scriptedEventsKit.package` from ZeroMind (search **scriptedEventsKit**), or copy the folder into `/source`. It depends on nothing, so the install brings no other kit. The optional kits it works with (interactKit, inventoryKit, tensionKit, saveKit, pickupsKit, soundstage, juiceKit) are handed over by the game through `scriptedEventsKit.links`, by their dotted module names: `require("~scriptedEventsKit.links").link("interactKit.api", require("~interactKit.api"))`. `require("~horrorKit.api")` links every one it installs. A trigger or beat whose kit is not linked does nothing. eerieLightsKit lights are found by entity name and group tag, with no link.
2. `local Cues = require("~scriptedEventsKit.api")` from any component, module or scene entrypoint.
3. Define cues when play starts (a scene `entrypoint.luau`, or a component's `start`), or place a **Cue** component on an entity.
## First example
```lua
local Cues = require("~scriptedEventsKit.api")
Cues.define("lightsOut", {
trigger = { kind = "area", entity = "hallTrigger", size = { 4, 3, 2 } },
once = true,
beats = {
{ "light", "hallLight*", "short" }, -- every light named hallLight...
{ "wait", 2 },
{ "show", "shape" },
{ "sound", "sk_sting", at = "shape" }, -- heard by everyone near it (a name scaresKit registers; without scaresKit pass a soundClip ref)
{ "flash", "red", alpha = 0.4 }, -- only the player who walked in
{ "message", "It is in here with you.", style = "whisper" },
{ "wait", 1.5 },
{ "hide", "shape" },
{ "light", "hallLight*", "restore" },
},
})
```
Or with no code: add `scriptedEventsKit.Cue` to an empty entity, set `size`, and fill `beats` with the same list. The editor draws its trigger box.
## Triggers
A cue takes one trigger or a list of them (any one fires it). `local` triggers are watched by each player's own engine for that player; `host` triggers by the host. Either way the host decides.
| kind | where | fields | fires when |
|---|---|---|---|
| `area` | local | `entity` or `at`, `size = {x,y,z}`, `shape = box/sphere`, `radius`, `on = enter/exit/inside`, `seconds` | a player enters / leaves / stays inside a box or sphere (uses an interactKit TriggerVolume's size if the entity has one) |
| `proximity` | local | `entity`, `radius = 3`, `on` | a player gets within `radius` of an entity, which may move |
| `look` | local | `entity` or `at`, `angle = 12`, `range = 25`, `seconds = 0.4`, `los = true` | the player keeps it inside a view cone for N seconds, with line of sight |
| `timer` | host | `after`, `from = "start"` or a cue id, `every` | N seconds after level start or after another cue fired; `every` repeats |
| `cue` | host | `after = "cueA"`, `delay` | chain: right after (or `delay` s after) cue A fires |
| `pickup` | host | `item`, `entity` | an item is picked up (interactKit Item collect, pickupsKit, or `Cues.notify("pickup", {item, peer})`) |
| `interact` / `door` | host | `entity`, `event = use/open/close/on/off/unlock/...` | an interactKit device is used, a door opens |
| `dread` | local | `above = 0.7` | the player's dread (tensionKit) rises past a level; nothing happens without tensionKit |
| `event` | host | `name` | your code calls `Cues.notify(name, { peer, at })` |
| `manual` | host | | only `Cues.fire(id)` |
Add your own with `Cues.registerTrigger(kind, { where, setup, tick })`.
## Beats
Beats run in order; only `wait` (and any beat with `wait = true` or `wait = seconds`) holds the timeline. `{"kind", main, second, field = ...}`: the first entry after the kind fills the main field.
| beat | scope | main, second | other fields |
|---|---|---|---|
| `wait` | time | seconds (or `{min,max}`) | |
| `sound` | world | clip | `at` (point/entity: 3D for everyone; none: 2D for the targeted players), `volume`, `maxDistance`, `pitch`, `loop`, `duration`. Clip = a soundClip ref, a name registered with `Cues.registerSound`, or a soundstage `"bank.sound"` |
| `light` | world | target, state | `on / off / flicker / short / restore / dim`; eerieLightsKit `LightBehavior.state` when present, else `Light.intensity`; `duration`, `level`, `intensity`, `style` |
| `animate` | world | target | `to = {pos, rot, scale}` or `by = {...}`, `duration`, `ease` (linear, inQuad, outQuad, inOutQuad, inCubic, outCubic, inOutSine, outBack, outBounce, slam, snap), `space = local/world` |
| `move` | world | target | `to` (point/entity), `rot` |
| `show` / `hide` | world | target | entity and all its children (models and lights) |
| `spawn` | host | model | `at`, `rot`, `scale`, `material`, `asset`, `physics = dynamic`, `mass`, `collider`, `light`, `lifetime`, `name` |
| `despawn` | world | target | |
| `impulse` | world | target | `force = {x,y,z}` or `from` + `strength` (+ `up`) |
| `shake` | personal | preset | juiceKit preset (`shakeLight`, `shakeHeavy`, `shakeRumble`, `shakeKick`, ...), `intensity` |
| `nudge` | personal | from | a small kick of the view away from a point |
| `look` | personal | at | eases the view toward a point, holds, hands it back: `turn`, `hold`, `release`, `strength` |
| `flash` | personal | color | `white / red / black / {r,g,b}`, `alpha`, `attack`, `hold`, `fade` |
| `fade` | personal | color | `duration`, `hold`, `back` (seconds, or `false` to stay dark) |
| `message` | personal | text | `style = subtitle / whisper / title / objective`, `speaker`, `duration` |
| `cutscene` | personal | def | an engine `cutscene.play` definition |
| `flag` | host | name, value | sets a world flag |
| `fire` | host | cue | fires another cue (its rules apply unless `force`), `delay` |
| `reset` | host | cue | forget that a cue fired |
| `enable` | time | cue | `on = false` turns it off |
| `call` | world | name | runs `Cues.register(name, fn)` on every peer: `fn(ctx, beat)`. The function's name is the beat's `name` field (where its main value lands), so a beat field called `name` REPLACES the function name: `{ "call", "spawnCorpse", name = "Ada" }` calls a function named `Ada`. Name it with `fn` instead to keep `name` for your data: `{ "call", fn = "spawnCorpse", name = "Ada" }` (`fn` wins when both are given) |
Every beat takes `chance = 0..1` and `only = "host"`. `Cues.registerBeat(kind, fn, { scope, main, second })` adds a beat; `fn(beat, ctx)` may return its length in seconds.
Scopes: **world** beats run on every peer and each entity is written by the one peer allowed to (its owner, or each peer for its own unshared copy), so every player sees the same door; **personal** beats run only for the cue's targeted players; **host** beats only on the host; **time** beats on everyone.
## Rules and conditions
| field | meaning |
|---|---|
| `once = true` | default: fires once per session (and per save with a state store) |
| `times = n` | fires at most n times |
| `["repeat"] = true`, `cooldown = s` | fires again after a cooldown |
| `when = { flags, notFlags, after, notAfter, item, test }` | needs flags set / unset, other cues fired / not fired, the triggering player holding an item (interactKit or inventoryKit), or your test |
| `players = "trigger" / "all" / "near"`, `near = 12` | who gets personal beats |
| `gate = fn(cue, ctx)` / `Cues.setGate(fn)` | a director may veto any fire |
| `enabled`, `label`, `data`, `save = false` | |
## API
| call | what it does |
|---|---|
| `Cues.define(id, spec)` / `undefine(id)` / `get(id)` / `list()` | author cues |
| `Cues.fire(id, { force, by, at })` | ask the host to fire it (manual trigger) |
| `Cues.fired(id)` / `hasFired(id)` / `isRunning(id)` / `whyNot(id)` | the ledger |
| `Cues.reset(id)` / `resetAll()` / `stop(id)` / `setEnabled(id, on)` | testing and control |
| `Cues.setFlag(name, v)` / `flag(name)` / `flags()` | world flags |
| `Cues.on(event, fn)` | events, returns a disconnect |
| `Cues.notify(name, data)` | feed `event` / `pickup` / `door` triggers from your code |
| `Cues.registerBeat` / `registerTrigger` / `register` / `registerSound` / `registerMaterial` | extend |
| `Cues.playBeats(list, opts)` | play a beat list on this peer only (directors, previews) |
| `Cues.setStateStore({get,set})` / `useSaveKit()` | keep the ledger between sessions |
| `Cues.setGate(fn)` / `setDebug(on)` | director veto; draw trigger volumes in play |
| `Cues.beatKinds()` / `triggerKinds()` | what is registered |
## Events
| event | data |
|---|---|
| `cueFired` | `{ id, by, count, origin }` (every peer) |
| `beat` | `{ id, index, kind, ran }` (every peer; `ran` false where a personal beat was not for this player) |
| `cueDone` | `{ id, by }` |
| `denied` | `{ id, by, reason }` (on the deciding peer) |
| `flag` | `{ name, value }` |
| `reset` | `{ id }` |
## Multiplayer
- The host decides every fire against one ledger (fired counts, last fire times, flags) that every peer mirrors; a cue fires once for the world even when two players walk in on the same frame.
- The host broadcasts `cue:run` with a start time on the session clock; every peer plays the beats from it, so doors, lights, props and positional sounds line up on every screen.
- Personal beats (flash, fade, shake, look, message, 2D sound) reach only the players the cue targets.
- A player who dies, respawns or rejoins keeps the world's ledger: a late joiner asks the host for a snapshot; a new host already has the mirror.
- With `Cues.setStateStore` (or `useSaveKit()`) the host writes the ledger so fired-once cues stay fired between sessions.
## Components
- **Cue**: a cue as fields (quick trigger + beats list, or a full `spec`); draws its area in the editor.
- **CueRunner**: spawned by the kit, one per peer in play; never added by hand.
## Known limits
- A cue defined with `Cues.define` lives in the kit's module state: it stays defined across play sessions in the same engine and fires again in the next session. Define cues where play starts (entrypoint `onLoad`, a component's `start`), not from a one-off script, or `undefine` them.
- The forced `look` is a glance: the builtin first-person controller keeps its own yaw and pitch, so the view eases toward the point and back rather than staying turned.
- Entities are addressed by name, glob or parent (the engine has no tag API); a light group is a parent entity or a name pattern.
- Beat sound and material names must be registered refs (`Cues.registerSound`); a world cannot resolve asset names computed at runtime and still publish.
- A cue's own beats are not replayed for a player who joins after it ran; state that must persist (an opened door, a spawned prop) should live on synced entities or flags.
## 1.0.4
The `call` beat also takes its function name from `fn`, so a beat can carry a data field called `name` (before, `name` is where the beat's main value lands, so a `name` field silently replaced the function name). README documents the clash. The package test reads the package.yaml and README beside the install, so it passes under deps/ and showcase/ too. New test.
## 1.0.3
The tests wait for the preview pictures a fresh install is still drawing before each test, so their first run no longer logs "camera texture not found" errors. No changes outside the tests.
## 1.0.2
README only: the install brings the packages `package.yaml` declares (it said it needed none); the first example's `sk_sting` sound is a name scaresKit registers; a cue defined from code stays defined in that engine across play sessions, so define it once (an entrypoint or a component's `start`).
## 1.0.2 (links)
Depends on nothing: tensionKit, interactKit, inventoryKit and saveKit are no longer declared, and no optional kit (pickupsKit, soundstage, juiceKit included) is required by name any more. They are linked by the game through `scriptedEventsKit.links`; `require("~horrorKit.api")` links them.
## 1.0.1
Renamed from cueKit. Declares its dependencies with versions. Test suite renamed scriptedEventsKitTests.
# loreKit
Version **1.0.6**.
Notes, documents and audio logs that tell your game's story. Put a **Lore** component on a prop and the player can read it: a full-screen **reader** opens in one of **seven styles**, switched by one field. Everything found goes into the player's **journal** with unread markers, saved per player through saveKit. Reading pauses nothing (the world keeps running for everyone), it closes with **Esc**, the pad's **B**, or a big **tap** target, and it is sized for phones and tablets. Ships nine original example entries, two generated voice logs and two generated photos.
## Install
Install `loreKit` from ZeroMind. It needs nothing else and installing it brings no other kit. It works with these when the game links them (`require("~loreKit.links").link("interactKit.api", require("~interactKit.api"))`; `require("~horrorKit.api")` links all three):
| Kit | Used for |
|---|---|
| interactKit | the standard Read prompt on a Lore prop (E / pad X-west / touch button, look-at or proximity) |
| saveKit | saving each player's journal (`Save.set("loreKit", ...)`) |
| soundstage | ducking music and ambience under a tape |
## First example
```lua
local Lore = require("~loreKit.api")
Lore.define({ id = "first_note", style = "note", title = "A torn page", body = "Don't run. It hears the grating." })
-- on a prop, in the editor: add loreKit.Lore, set id = "first_note" (or write title/body there)
-- or from code, on any prop (here a new one):
local prop = entity.spawn("tornPage")
prop.component.add("loreKit.Lore", { id = "first_note" })
Lore.on("read", function(e) if e.first then print("found", e.id) end end)
```
In play, walk up to the prop and press E. Press **J** (or the pad's View/Select, or tap the badge) for the journal.
## Reader styles (`style` = one field)
| Style | What the player sees and hears |
|---|---|
| `note` | handwritten italic on stained, creased paper, slightly askew; paper rustle |
| `memo` | typed office memo: letterhead, FROM / DATE / SUBJ, typewriter face, CONFIDENTIAL stamp |
| `terminal` | CRT terminal; green phosphor text types itself out with a blinking cursor (`variant = "amber"` for amber); beep and keys |
| `tape` | dictaphone deck with spinning reels, timer and progress; plays the entry's `clip` with tape hiss and timed subtitles (from `subtitles`, or made from the body's sentences); music ducks under it |
| `graffiti` | big rough red letters scrawled on a grimy wall |
| `datapad` | sci-fi tablet: bezel, glowing header bar, clean type |
| `photo` | pinned instant photo (`image`) with a handwritten `caption` |
`Lore.open(id, { style = "terminal" })` shows any entry in another style.
## Entries
`{ id, style, title, body, author?, date?, clip?, subtitles? = { { at, text } }, image?, caption?, variant? }`. `clip` is a soundClip ref (or a loreKit clip name), `image` a texture reference (or a loreKit image name).
Examples (original, a half-flooded deep-sea research station): `ring_c_note` (note), `curfew_memo` (memo), `sonar_terminal` (terminal), `tape_varga_14` and `tape_reyne_02` (tape, generated voices), `scrawl_light` (graffiti), `pad_manifest` (datapad), `crew_photo` and `camera_still` (photo, generated images).
## The Lore component
Fields: `id`, `style` (`default` or one of the seven), `title`, `body`, `clip`, `label` ("Read"), `range` (2.2 m), `trigger` (`look` / `proximity`). With interactKit it adds an Interactable beside itself; without it, E or the pad's west button opens it within range. Event `read{id}`. Only the player who used it reads it.
## API (`require("~loreKit.api")`)
| Call | Does |
|---|---|
| `define(entry)`, `get(id)`, `ids()` | the catalogue |
| `open(id, opts?)` | open the reader (finds + marks read + fires `read`). `opts.style`, `opts.source` |
| `close()`, `current()` | close the reader or journal; the open id |
| `find(id)` | add to the journal without opening (true the first time) |
| `markRead(id)`, `isFound(id)`, `isRead(id)` | journal state |
| `journal()`, `unread()` | `{ { id, title, style, read } }` oldest first; unread count |
| `openJournal()`, `toggleJournal()`, `resetJournal()` | the journal screen; a new game |
| `setSubtitles(on)`, `subtitles()` | this player's tape subtitles on or off (default on), for a settings menu; saved in their saveKit profile (`loreKit.settings`) when saveKit is linked; an open tape redraws at once. `open(id, { subtitles = false })` overrides it for one open |
| `STYLES`, `STYLE_INFO`, `VERSION` | |
## Events
| Event | Payload |
|---|---|
| `read` | `{ id, style, title, first, source }` |
| `found` | `{ id, title }` |
| `opened` / `closed` | `{ id }` / `{ id, seconds }` |
| `journal` | `{ open }` (or `{ loaded = true }` after saveKit loads it) |
| `settings` | `{ subtitles }` (and `loaded = true` when a saved choice was applied) |
## Input
| | Keyboard / mouse | Gamepad | Touch |
|---|---|---|---|
| Read | E (interactKit prompt) | X / west | Interact button |
| Close | Esc, Backspace, ✕ button, click outside | B / east | tap ✕ (56 pt tall) or outside |
| Journal | J | View / Select | tap the badge |
## Multiplayer
The reader, journal and badge are local to each player: reading pauses nothing for anyone, and only the player who used a Lore prop sees it. Each player's journal is their own and is saved in their own saveKit profile. Entries defined in code exist on every engine that runs that code.
## Known limits
- Without saveKit the journal lasts the session only.
- Tape subtitles made from the body are timed by sentence length; give `subtitles` for exact timing.
- The badge and journal key are fixed per host (`LoreHost.journalKey`, default J).
## 1.0.1
Escape closes only the open reader or journal; it no longer also opens the engine menu. Declares its dependencies with versions.
## 1.0.2
Installs alone: interactKit, saveKit and soundstage are linked by the game through `loreKit.links` instead of being required by name; `require("~horrorKit.api")` links them.
## 1.0.3
README: the first example spawns the prop it adds Lore to, so it runs as written.
## 1.0.4
The reader test no longer leaves engine errors behind: it removed the reader screen in the same frame it showed it (14 "parent never materialized" errors per run). It now lets each screen settle before closing it. The reader itself is unchanged.
## 1.0.5
The tests remove everything each test left behind and wait for previews a fresh install is drawing, so a passing run leaves no errors. No changes outside the tests.
## 1.0.6
Subtitles can be turned off. `Lore.setSubtitles(false)` hides the tape reader's timed subtitles for this player (a settings menu toggle), `Lore.subtitles()` reads it, and `Lore.open(id, { subtitles = true | false })` overrides it for one open. The choice is saved per player through saveKit (key `loreKit.settings`) when it is linked, an open tape redraws at once, and the `settings` event fires. Default unchanged (on). New test covers it.
# Brinefall Station
A short, original survival-horror level built entirely from installable parts: the horror kit (`horrorKit` and the packages it installs) and `bulkheadKit` for the station itself. It is both a level to play and a worked example to read.
1986, a research habitat 480 m down on the lip of a trench, silent for nine days. You are a contract diver sent down in the station's own diving bell. Something in the ducts has learned the station's sounds, and it follows light.
## What it contains
| module | what |
|---|---|
| `brinefall.layout` | the station's 11 rooms and their dressing (bulkheadKit), returning named anchors |
| `brinefall.content` | doors, the red keycard and its lock, the breaker lever, lore props, scarce supplies, the med-bay safe room and save terminal, the two monsters and their vents, the HorrorDirector |
| `brinefall.story` | the eight lore entries (notes, memos, terminals, tapes) |
| `brinefall.script` | the scripted beats: five scares, the pursuer encounter, the breaker, the finale and the ending |
| `brinefall.playtest` | plays the level start to end with real input and reports when each of the 12 cues fired, how often, every scare and monster state (`require("brinefall.playtest").run()` in play) |
`DESIGN.md` has the route, the beats and the story.
## Use it
The scene build calls `Layout.build(root)` and then `Content.build(anchors)`; `brinefall.LevelScript` (placed on the HorrorDirector) and the scene entrypoint's `onLoad` call `require("brinefall.script").start()`. Everything a player shares (doors, monsters, scripted events, lights) is synced or host-decided, so two players see the same station.
## 1.0.17
On horrorKit 1.0.21 (saveKit 1.3.21). No code changes.
## 1.0.16
On horrorKit 1.0.20, which states controlsKit 1.4.7; use 1.0.17. No code changes.
## 1.0.14
On horrorKit 1.0.18 and bulkheadKit 1.0.3. No code changes.
## 1.0.13
On horrorKit 1.0.13. No code changes.
## 1.0.12
On horrorKit 1.0.12. No code changes.
## 1.0.11
On horrorKit 1.0.11. No code changes.
## 1.0.10
On horrorKit 1.0.10. No code changes.
## 1.0.9
On horrorKit 1.0.9: no saveKit XP bar over the level, quiet when play stops.
## 1.0.8
On horrorKit 1.0.8.
## 1.0.7
On horrorKit 1.0.7.
## 1.0.6
- Every scare fires once at its moment: the knock and the shape crossing are essential now, like the lights-closer, body drop and dock slam. In one playthrough the tension director's pacing vetoed both as the player walked through, and a walk-through trigger does not come back, so they were lost for that run.
- New `brinefall.playtest`, the playthrough driver the 2026-11-23 runs used.
- On horrorKit 1.0.6.
## 1.0.5
On horrorKit 1.0.5.
## 1.0.4
On horrorKit 1.0.4 and bulkheadKit 1.0.2.
## 1.0.3
- No longer depends on stealthKit. The HUD keeps its light and noise element on (`showStealth`); it draws when the world places `horrorStealthLink.StealthReadout`, which this world's scene does, and draws nothing otherwise. Declares menusKit (the ending screen) and horrorKit 1.0.3.
## 1.0.2
- `start()` now waits for play to settle when the entrypoint calls it during the edit to play flip (engine.mode still "edit"); before, a fresh engine defined no cue at all and no beat fired.
- The scene entrypoint hook is `onLoad` (this engine has no `onLoadDefault`). `brinefall.LevelScript` (new component on HorrorDirector) starts the beats on the edit to play flip. The start guard is a time stamp, not a flag kept in module state.
- Moon-pool blockers are 3 m tall (a jump cleared the 1.4 m ones into the shaft). lightsCloser is essential (the pacing gate could drop it for good). The gallery console loads the gallery from a system task (a load started by the scene it unloads stalled half-way).
# scaresKit
Named **scaresKit** since 1.0.1 (it was published as scareKit in 1.0.0). Search for either name.
**26 original horror scares, from a distant scream to a body dropping from the ceiling, each placeable with one call or one component and rated by intensity 1 (subtle) to 5 (huge).** Every scare builds its own props, plays its own generated sound, and runs as a [scriptedEventsKit](../scriptedEventsKit.package/README.md) cue, so it fires once for the whole multiplayer world and stays fired after the player dies and respawns. A tension director can list, pick, veto and hear every scare.
Version **1.0.5** (`Scares.VERSION`). The version, this README and `package.yaml` move together.
## Install
1. Install `scriptedEventsKit.package` and `scaresKit.package` (search ZeroMind for **scaresKit**; scriptedEventsKit is its one dependency). tensionKit (the director gate) and interactKit (the `interact` beat, door slams on an interactKit door) are optional: link them with `require("~scaresKit.links").link("tensionKit.api", require("~tensionKit.api"))` (same for `interactKit.api`); `require("~horrorKit.api")` links both.
2. `local Scares = require("~scaresKit.api")`.
3. In a scene entrypoint (or any code every peer runs in play): `Scares.place("doorSlam", { at = {0, 0, 5}, facing = 180 })`, or put a **Scare** component on an empty entity.
## First example
```lua
local Scares = require("~scaresKit.api")
-- the player walking into the spot (radius 2.5 m) fires it; props are built ahead of them
Scares.place("ventBurst", { at = { 4, 0, 9 }, facing = 90 })
-- lights die and something is closer each time, using the corridor's own lights:
-- hallStart and hallEnd are entities at the two ends of the corridor (your level has its own; these are spawned here)
local hallStart = entity.spawn("hallStart"); hallStart.position = vector.create(0, 0, 40)
local hallEnd = entity.spawn("hallEnd"); hallEnd.position = vector.create(0, 0, 52)
Scares.place("lightsCloser", { at = "hallStart", toward = "hallEnd", lights = "hallLight*" })
-- fire when the player LOOKS at the window for a second
Scares.place("handPrint", { at = { 0, 0, 20 }, trigger = { kind = "look", at = { 0, 1.5, 22.5 }, seconds = 1 } })
-- let the director choose what plays here, up to intensity 3
Scares.slot({ at = { -6, 0, 30 }, maxIntensity = 3 })
```
**Placement convention:** `at` is where the player stands when it fires; `facing` (yaw degrees, 0 = +z) or `toward` (a point or entity) is the way they look. Props are built ahead of them. The default trigger is an area of `radius` (2.5 m) at `at`; `mannequinTurn` uses a look trigger.
## The scares
| id | label | intensity | tags | props | what happens |
|---|---|---|---|---|---|
| `distantScream` | Distant scream | 1 | sound, distant, fakeout | | a scream far down the corridor ahead (`distance`) |
| `knock` | Knock on a door | 1 | sound, door, fakeout | | three slow knocks from behind `door` |
| `lightPop` | A bulb pops and dies | 1 | light, sound | lamp | the light above crackles, flares, dies, limps back (`lights`) |
| `shelfFall` | Bottle falls off a shelf | 1 | object, sound | shelf, bottle, cans | a bottle tips off a shelf and clatters down |
| `whisper` | Whisper in your ear | 2 | sound, personal, fakeout | | a whisper at the ear of the triggering player only (`text` optional) |
| `footstepsBehind` | Footsteps behind you | 2 | sound, personal, fakeout | | heavy steps right behind the player |
| `chairSlide` | Chair slides on its own | 2 | object, sound | chair | a chair scrapes across the floor and turns to you |
| `radioVoice` | Radio voice in the static | 2 | sound, object, lore | radio, crate | a dead radio crackles: a voice says something it should not know (`text`) |
| `waterSplash` | Splash in the dark water | 2 | sound, water, fakeout | ripple | something heavy goes under; rings spread |
| `breathingDoor` | Breathing behind a door | 2 | sound, door | | slow wet breathing behind `door` |
| `glassCrack` | Glass cracks | 2 | object, sound, glass | pane, cracks | a crack crawls across the window, line by line |
| `shadowSlide` | A shadow slides along the wall | 2 | light, visual, shadow | shadow | a tall shadow glides along a wall (`side`); eerieLightsKit Silhouette when present |
| `shapeCross` | A shape crosses the far end | 3 | figure, visual, corridor | figure | a tall wrong shape crosses the far end fast (`distance`, `width`) |
| `monitorFace` | Monitor shows a face | 3 | object, visual, screen, sound | desk, CRT monitor | a dead screen thunks on; a face of three dark dots resolves in the glow |
| `handleRattle` | Door handle rattles | 3 | door, sound, object | door | the handle jerks hard as if someone wants in (`door`) |
| `handPrint` | Hand print on the glass | 3 | glass, visual, sound | pane, hand | a wet palm slaps the glass and drags down; nobody there |
| `mannequinTurn` | The figure has turned | 3 | figure, visual, look | mannequin | look at it, look away, look back: it faces you, closer |
| `ceilingRun` | Something runs across the ceiling | 3 | sound, ceiling, fakeout | | thumps race overhead and away; the view shakes |
| `alarm` | Alarm blares | 3 | sound, light, loud | beacon | a red beacon spins and a klaxon tears the silence (`seconds`) |
| `doorSlam` | Door slams shut | 4 | door, sound, loud | door | the heavy door slams with a boom (`door` = an interactKit door to close, else its own) |
| `ventBurst` | Vent cover bursts open | 4 | object, sound, loud, vent | vent | a grille rattles, bangs off and clatters to your feet |
| `lightsCloser` | Lights die; it is closer each time | 4 | light, figure, visual | lamp, figure | out, back: a figure far off; out, back: halfway; out, back: right there; out: gone (`lights`, `marks`) |
| `pipeBurst` | Pipe bursts with steam | 4 | object, sound, loud, steam | pipe, steam | a pipe bangs and splits; steam blasts across the corridor |
| `powerFailure` | Power failure | 4 | light, sound, dark | lamp | everything winds down; seconds of black; emergency power stutters back (`lights`, `seconds`); sets flag `scaresKit.powerRestored` |
| `bodyDrop` | Body drops from the ceiling | 5 | object, loud, visual | body on a rope, lamp | a body in a stained sheet drops on a rope in front of you, jerks and swings |
| `chaseSting` | Chase sting | 5 | sound, personal, chase, music | | screeching hit and drums, red flash, view snaps toward `from`; sets flag `scaresKit.chase` |
All creatures, names and designs are original to this kit. The figure is a gaunt 2.3 m silhouette with overlong arms and a head tilted onto its shoulder.
Every scare has its own generated sound (`sounds/sk_*.soundClip`, 27 clips), registered with scriptedEventsKit by name so any cue can use them: `{"sound", "sk_doorSlam", at = "door"}`.
## Placement options
`at`, `facing` / `toward`, `trigger` (any scriptedEventsKit trigger), `radius`, `cueId`, `once`, `repeat` + `cooldown`, `times`, `players = trigger/all/near`, `when` (scriptedEventsKit conditions), `essential`, plus each scare's own needs: `lights`, `door`, `text`, `distance`, `width`, `marks`, `seconds`, `side`, `from`.
`essential = true` lets the scare skip the director's gate (tensionKit's pacing, or your own `setGate`). Use it for a beat the level depends on, such as a scare that releases a monster or that the finale chains from. A gated scare normally stays armed and fires once the director allows it. That only holds for a trigger that hits again, like an area or a look. A scare triggered by a pickup or a chained cue hits once, so it is essential by default: vetoed at that moment, it and everything chained after it would never happen.
## API
| call | what it does |
|---|---|
| `Scares.place(id, opts)` | build the props and arm the cue; returns the cue id |
| `Scares.remove(cueId)` / `placed()` / `trigger(cueId, force)` | manage placed scares |
| `Scares.get(id)` | a scare's card: `{ id, label, intensity, tags, props, needs, desc }` |
| `Scares.list({ maxIntensity, minIntensity, tags, without, gated })` | the library, filtered, sorted by intensity |
| `Scares.pick({ ...list opts, prefer = "random"/"strongest", exclude, seed })` | a director's choice among scares the gate allows |
| `Scares.setGate(fn(card) -> boolean)` | the director's veto, asked on the host before every scare fires |
| `Scares.useDreadKit()` | tensionKit as the director (once `tensionKit.api` is linked in `scaresKit.links`): `canScare` gates, `scared` hears every scare |
| `Scares.slot({ at, trigger, maxIntensity, tags, candidates, choose })` | a director-chosen slot |
| `Scares.on("scare" / "placed", fn)` | events, returns a disconnect |
| `Scares.sounds.CLIPS` / `names()` | the kit's sound refs |
## Events
| event | data |
|---|---|
| `scare` | `{ id, intensity, position = {x,y,z}, cueId, by }`, on every peer when a placed scare fires |
| `placed` | `{ id, cueId }` |
## Components
- **Scare**: one scare on an entity: `scare` (id or `director`), `trigger` (default / area / look / manual / timer), `radius`, `seconds`, `lookAt`, `lights`, `door`, `text`, `players`, `once`, `maxIntensity`, `tags`, `options`. Its props are previewed in the editor.
## Multiplayer
Place scares from code every peer runs (a scene entrypoint, a component): each peer builds the same props under the same names, and scriptedEventsKit's host decides the fire once and every peer plays the same beats from the same start time. Personal parts (whisper, footsteps behind you, flashes, shakes, the chase sting) go only to the players the cue targets (`players`).
## Known limits
- Props are procedural (primitive meshes with tinted materials); swap in your own art by hiding the kit's parts and animating yours with scriptedEventsKit beats.
- Falling and flying props are animated with easing rather than simulated, so every peer sees the same motion.
- The dark is the scene's: scares land hardest in a dim level where their lamps and lights carry the moment.
## 1.0.1
Renamed from scareKit; depends on scriptedEventsKit 1.0.1. Test suite renamed scaresKitTests.
## 1.0.2
Depends on scriptedEventsKit 1.0.2 (README fixes; cues defined from code stay defined across play sessions). The scares themselves are unchanged.
tensionKit and interactKit are linked through `scaresKit.links` rather than required by name, so scaresKit installs with scriptedEventsKit alone.
## 1.0.3
README: the first example spawns the corridor ends `lightsCloser` names (`hallStart`, `hallEnd`), so it runs as written in an empty world. The version test reads the right `package.yaml` path.
## 1.0.4
On scriptedEventsKit 1.0.3. No code changes.
## 1.0.5
On scriptedEventsKit 1.0.4. No code changes.