# 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.
# flashlightKit 1.0.4, flashlights, lanterns, flares and batteries for horror games
Named **flashlightKit** since 1.0.1 (it was published as torchKit in 1.0.0). Search for either name.
A handheld light for first-person horror, survival and exploration games. Put one component on the player and they get a real shadow-casting light that lags and sways with the view, a held model with a glowing lens, a click, and a battery that runs down, browns out, stutters and dies. Twelve styles are switched by one field, from the classic torch to a swinging oil lantern, a red road flare you can throw, a glow stick, a guttering candle, a hand-crank dynamo torch, a UV black light that shows hidden writing, and a camera flash.
## Install
Search ZeroMind for **flashlightKit** and install it. Its `package.yaml` declares interactKit 1.6.8 and inventoryKit 1.0.27, so the install brings them and the kits under them (in an empty world: interactKit, inventoryKit, controlsKit, juiceKit, saveKit, menusKit, pickupsKit, SecondWind, Lifeline, MatchFlow) into `/source/deps/`. The torch works without using them: the battery bag and use prompts are the only parts that read them.
## First example
Put the component on the body of your player prototype (every player who joins gets their own torch):
```lua
-- In a game this goes on your player prototype's body (in the scene's build). To try it anywhere,
-- here is a stand-in body to carry it:
local body = entity.spawn("torchCarrier")
body.position = vector.create(0, 1.6, 0)
body.component.add(asset.resolve("flashlightKit.Torch", "component"), { style = "classic", spares = 2 })
```
Press **F** (gamepad d-pad up, or the on-screen **Torch** button on a phone) to switch it on. **V** shakes it (fixes a loose contact, cranks a dynamo while held, throws a flare or glow stick). **B** swaps in a spare battery. A small battery meter sits bottom-left.
Story code:
```lua
local Torch = require("flashlightKit.api")
Torch.on("batteryLow", function(e) print("low", e.charge) end)
Torch.flicker(nil, 2.5, 0.8) -- this peer's player: a hard 2.5 s flicker
Torch.fail(nil, "brownout") -- fades out until restored
task.delay(4, function() Torch.restore(nil) end)
```
## Styles
| style | light | colour | cone / range | battery | runs low by | extras |
|---|---|---|---|---|---|---|
| `classic` | shadowed spot + faint wide spill | warm white | 24° half, 26 m | `alkaline` (10 min) | brown-out fade with dips | held torch, glowing lens |
| `penlight` | narrow spot | white | 12° half, 14 m | `aaa` (7 min) | loose contact (shake to fix) | thin pen model; random contact faults |
| `lantern` | omni point | orange | 9 m | `oil` (15 min) | sputter | swings on its bail as you turn and walk |
| `headlamp` | spot on the head, no lag | cool LED | 30° half, 20 m | `pack` rechargeable (12 min) | steps down to low mode, then cuts out | no held model, hands free |
| `phone` | wide weak spot | cold blue-white | 46° half, 11 m | `phone` (8 min) | sudden death at 0 % | phone model with lit screen |
| `flare` | omni point | red | 14 m | `flare` (2.5 min burn) | sputters out | hissing loop; **V** throws it (keeps burning where it lands) |
| `glowstick` | omni point | green | 6 m | `chemical` (30 min) | never dies, dims to 30 % | **V** throws it |
| `candle` | tiny omni | orange | 6 m | `wax` (20 min) | gutters | blown out when you run; **F** relights |
| `dynamo` | spot | warm | 26° half, 20 m | `dynamo` (50 s per full crank) | brown-out | hold **V** to crank (ratchet sound) |
| `uv` | spot | violet | 22° half, 12 m | `alkaline` (7 min) | loose contact | reveals `UVReveal` surfaces in its cone |
| `cameraFlash` | blinding spot for 0.16 s | daylight | 48° half, 24 m | `flashcell` (40 flashes) |, | **F** fires; 2.2 s recharge; `flash` event |
| `lighter` | tiny omni | orange | 5 m | `butane` (5 min) | gutters | blown out when you sprint |
`require("flashlightKit.styles").define(id, fields, base)` adds your own; any field left out comes from the base.
## Batteries
`alkaline`, `aaa`, `pack` (rechargeable), `oil`, `flare`, `dynamo` (rechargeable by cranking), `phone` (rechargeable), `chemical`, `wax`, `flashcell`, `butane`. Each has a discharge curve (alkaline sags gradually, Li-ion holds then drops off a cliff, oil and flares hold then sputter, phones die suddenly) and a `lowAt` threshold where the style's low-battery behaviour starts. Charge only drains while the light is on.
- **Spares**: the Torch's `bag` (synced table, `{ alkaline = 2 }`). `Torch.give(player, type, n)`, `Torch.swap(player)`, `Torch.spares(player)`.
- **BatteryPickup** component: batteries lying in the world (walk over, or `interact = true` with interactKit). With inventoryKit installed they go into the inventory as items (`torch_battery_aa`, `torch_battery_pack`, ...) and a swap takes from there.
- **ChargingStation** component: rechargeable types charge while the player stands within `radius`. `powered = false` cuts it (power outage).
## API (`require("flashlightKit.api")`)
`player` is nil (this peer's player), a player record, an entity, or an entity id. Every call works from any peer: the owner applies it and every peer sees the result.
| call | does |
|---|---|
| `Torch.flicker(player, seconds?, severity?)` | timed flicker, severity 0..1 |
| `Torch.fail(player, mode, seconds?)` | `brownout`, `contact` (until shaken), `sudden`, `sputter`, `flicker`, `stepdown`, `gutter`; nil seconds = until restored |
| `Torch.restore(player)` | clears failures and flicker |
| `Torch.setCharge(player, 0..1)` / `Torch.charge(player)` | battery |
| `Torch.isOn(player)` | giving light now; `Torch.switchedOn` = switch position |
| `Torch.lightOf(player)` | the Light entity on this peer |
| `Torch.set(player, on)` / `Torch.toggle(player)` / `Torch.setStyle(player, id)` | switching |
| `Torch.give` / `Torch.swap` / `Torch.spares` | spares |
| `Torch.visibility(player)` | 0..1 how visible the torch makes the player (style-weighted), feed it to monster sight |
| `Torch.lights(player, point)` | 0..1 how strongly the beam reaches a world point (cone + range) |
| `Torch.beams()` | every lit torch: position, forward, range, angle, level, visibility |
| `Torch.setQuality("high" \| "medium" \| "low")` | how many other players' torches cast shadows |
| `require("flashlightKit.hud").setEnabled(false)` | hide the built-in meter (draw your own from `Torch.charge` / `spares`) |
| `require("flashlightKit.audio").override(name, clip)` | swap any sound |
## Events (`Torch.on(name, fn) -> disconnect`)
`toggled{player,on}`, `batteryLow{player,charge}`, `batteryDead{player}`, `swapped{player,battery}`, `failed{player,mode}` (the names horrorKit wires), plus `flash{player}` and `charged{player,charge}`. They fire on the peer that owns the torch.
## Components
- **Torch**, the light (fields above plus `startOn`, `spares`, `drainScale`, `controls`, `meter`, `autoSwap`, `randomFaults`, `shadows`, `npc` for torches carried by NPCs or test dummies).
- **BatteryPickup**, **ChargingStation**, **UVReveal** (hidden writing), **ThrownLight** (spawned by a throw).
- Controls: `flashlightKit.torch` input map (group `torch`): `torchToggle` F / d-pad up / touch, `torchShake` V / d-pad down / touch, `torchSwap` B / d-pad left / touch.
## Multiplayer
Every player has their own torch. The owner writes `on`, `style`, `charge`, `fault`, flicker and aim `pitch` (synced, pitch only when it moves 2°); every peer draws every torch from those fields and the shared session clock, so flicker and brown-out look identical everywhere and nothing streams per frame. Battery is per player and owner-authoritative; story calls made on another peer are sent to the owner. Thrown flares are synced entities.
## Performance
About 0.04 ms of script per torch per frame (four torches measured at 0.17 ms). Light parameters are written only when they change. The owner's own torch always casts shadows; other players' torches cast shadows only when near (22 m) and within the quality budget. Held models are a handful of primitives with shadows off.
## Known limits
- **F** is also controlsKit's fps-scheme secondary interact key; interactKit's E is unaffected. Rebind `torchToggle` in `torch.inputMap` if your game uses F.
- Held models are built from primitives (no mesh assets), so they read as stylised props up close.
- **Darkness needs no sky in the scene.** A sky entity (the new-world template's `lighting` scene setup included) lights interiors even through a camera with `environment = "isolated"`, and it keeps doing so with its sun and ambient at 0: measured in an empty world, a closed room with every light and the torch off read mean 37/255 with the template's lighting left in, and 0.5/255 with it deleted. For an interior, delete the template's `lighting` entity and keep a near-black ambient `Light` of your own (switch it off with `intensity = 0`).
- flashlightKit alone does not tell monsters about your light. horrorKit wires it; without horrorKit, report it yourself on the player's own peer, for example `Stalkers.setPlayerLight(body, Torch.visibility(nil))` with stalkerKit, a few times a second.
- Two-peer play was verified through the remote drawing path (NPC torches use it), not with a second live player.
## 1.0.4
The held light follows the player's view only while the main camera is with the carrier. The rig placed the torch at whatever `camera.main()` names, so a game whose main camera was some other view (a title or establishing camera left as main, a camera rig whose Camera sits elsewhere) got a torch that reported on at full power while lighting a spot far from the player. Now, when the main camera is more than `Rig.EYE_REACH` (2.5 m) from the carrier's eye, the torch is held at the carrier's own eye (body + 1.6 m, turned by the body's yaw and the synced pitch) and one warning names the distance. New test covers both cases. Also measured for this release: in a closed bulkheadKit room under an `isolated` camera, the classic torch at intensity 41 lights the floor ahead and its own held model never shadows it (the model casts no shadows).
## 1.0.3
The first README example now makes its own stand-in body to carry the torch, so it runs as pasted into a world with only flashlightKit installed (it used a `body` it never set up). No code changes.
## 1.0.2
README only: the install brings interactKit and inventoryKit (it said it had no dependencies); darkness needs the template's sky deleted (it said a sky of the scene's own was enough); how to tell monsters about the light without horrorKit.
## 1.0.1
Renamed from torchKit. A battery pickup takes and gives exactly once per press, across reloads and play sessions. The held model, lens and battery use lit materials, so nothing glows when the light is off. Quality (shadow count) is picked from the device on its own (`setQuality(\"auto\")`). Declares its dependencies with versions.