Log inGet started
Package

scriptedEventsKit.package

README.md

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

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.

kindwherefieldsfires when
arealocalentity or at, size = {x,y,z}, shape = box/sphere, radius, on = enter/exit/inside, secondsa player enters / leaves / stays inside a box or sphere (uses an interactKit TriggerVolume's size if the entity has one)
proximitylocalentity, radius = 3, ona player gets within radius of an entity, which may move
looklocalentity or at, angle = 12, range = 25, seconds = 0.4, los = truethe player keeps it inside a view cone for N seconds, with line of sight
timerhostafter, from = "start" or a cue id, everyN seconds after level start or after another cue fired; every repeats
cuehostafter = "cueA", delaychain: right after (or delay s after) cue A fires
pickuphostitem, entityan item is picked up (interactKit Item collect, pickupsKit, or Cues.notify("pickup", {item, peer}))
interact / doorhostentity, event = use/open/close/on/off/unlock/...an interactKit device is used, a door opens
dreadlocalabove = 0.7the player's dread (tensionKit) rises past a level; nothing happens without tensionKit
eventhostnameyour code calls Cues.notify(name, { peer, at })
manualhostonly 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.

beatscopemain, secondother fields
waittimeseconds (or {min,max})
soundworldclipat (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"
lightworldtarget, stateon / off / flicker / short / restore / dim; eerieLightsKit LightBehavior.state when present, else Light.intensity; duration, level, intensity, style
animateworldtargetto = {pos, rot, scale} or by = {...}, duration, ease (linear, inQuad, outQuad, inOutQuad, inCubic, outCubic, inOutSine, outBack, outBounce, slam, snap), space = local/world
moveworldtargetto (point/entity), rot
show / hideworldtargetentity and all its children (models and lights)
spawnhostmodelat, rot, scale, material, asset, physics = dynamic, mass, collider, light, lifetime, name
despawnworldtarget
impulseworldtargetforce = {x,y,z} or from + strength (+ up)
shakepersonalpresetjuiceKit preset (shakeLight, shakeHeavy, shakeRumble, shakeKick, ...), intensity
nudgepersonalfroma small kick of the view away from a point
lookpersonalateases the view toward a point, holds, hands it back: turn, hold, release, strength
flashpersonalcolorwhite / red / black / {r,g,b}, alpha, attack, hold, fade
fadepersonalcolorduration, hold, back (seconds, or false to stay dark)
messagepersonaltextstyle = subtitle / whisper / title / objective, speaker, duration
cutscenepersonaldefan engine cutscene.play definition
flaghostname, valuesets a world flag
firehostcuefires another cue (its rules apply unless force), delay
resethostcueforget that a cue fired
enabletimecueon = false turns it off
callworldnameruns 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

fieldmeaning
once = truedefault: fires once per session (and per save with a state store)
times = nfires at most n times
["repeat"] = true, cooldown = sfires 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 = 12who gets personal beats
gate = fn(cue, ctx) / Cues.setGate(fn)a director may veto any fire
enabled, label, data, save = false

API

callwhat 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 / registerMaterialextend
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

eventdata
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.