api
The front door: `require("~interactKit.api")`. Registries of usable things, the owner-side decision for every request (reach, locks, stale state, hold claims), wiring (`fire`, `signal`), events (`on`, `emit`), prompt style setting, catalog and `spawn`, keys and items (`spawnKey`,…
interactKit.api
The front door: require("~interactKit.api"). Registries of usable things, the owner-side decision for every request (reach, locks, stale state, hold claims), wiring (fire, signal), events (on, emit), prompt style setting, catalog and spawn, keys and items (spawnKey, count, give, items, setInventory), juiceKit feedback (fx).
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
idOf(target: any) → string
| arg | type | description |
|---|---|---|
| target | any |
on(target: any, name: string, fn: any) → void
Listen for `name` on `target` (an entity, its id or name, or "*" for every entity). fn(data, entityId). Returns an unsubscribe function. Events: use, open, close, on, off, unlock, denied, loot, board, unboard, enter, exit, stay, holder.
| arg | type | description |
|---|---|---|
| target | any | |
| name | string | |
| fn | any |
emit(entityId: string, name: string, data: any?) → void
Fire `name` on this peer only.
| arg | type | description |
|---|---|---|
| entityId | string | |
| name | string | |
| data | any? |
eventSink(entityId: string, name: string, data: any, _from: number) → void
one-shot events from the network
| arg | type | description |
|---|---|---|
| entityId | string | |
| name | string | |
| data | any | |
| _from | number |
juice( ) → void
juiceKit's Juice, or nil and why not.
setEffects(on: boolean) → void
Turn the open/close effects off or on (they never change state).
| arg | type | description |
|---|---|---|
| on | boolean |
fx(preset: string, at: any, opts: any?) → void
Play a juiceKit preset on this peer only (every peer runs state changes itself).
| arg | type | description |
|---|---|---|
| preset | string | |
| at | any | |
| opts | any? |
keyOf(peer: number) → string
The key a player's items are counted under in interactKit's inventory ("p<peer>").
| arg | type | description |
|---|---|---|
| peer | number |
setInventory(src: any?) → void
Use your own inventory for keys and keycards instead of interactKit's: { count = fn(peer, item) -> number, give = fn(peer, item, n) }. nil goes back to interactKit's own. It is read on the owner of each lock.
| arg | type | description |
|---|---|---|
| src | any? |
count(peer: number, item: string) → number
How many of `item` player `peer` holds (interactKit's inventory, or the one given to setInventory).
| arg | type | description |
|---|---|---|
| peer | number | |
| item | string |
give(peer: number, item: string, n: number) → boolean
Give player `peer` n of `item` (negative takes; never below 0). Applied by the inventory's owner; from any other peer it is sent there.
| arg | type | description |
|---|---|---|
| peer | number | |
| item | string | |
| n | number |
items(peer: number) → any
Everything player `peer` carries in interactKit's inventory: { keys = 1, coins = 5, ... } (a copy).
| arg | type | description |
|---|---|---|
| peer | number |
registerInteractable(entityId: string, comp: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| comp | any |
unregisterInteractable(entityId: string, comp: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| comp | any |
registerDevice(entityId: string, dev: any) → void
A device registers its behaviour: { family, kind, comp, handle(peer, verb, args) -> ok, reason, status(peer) -> table, defaults, signal(action) }.
| arg | type | description |
|---|---|---|
| entityId | string | |
| dev | any |
unregisterDevice(entityId: string, dev: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| dev | any |
device(target: any) → any
| arg | type | description |
|---|---|---|
| target | any |
registerLock(entityId: string, lock: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| lock | any |
unregisterLock(entityId: string, lock: any) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| lock | any |
lock(target: any) → any
| arg | type | description |
|---|---|---|
| target | any |
vec(v: any, fallback: { number }) → void
| arg | type | description |
|---|---|---|
| v | any | |
| fallback | { number } |
settingsOf(entityId: string) → any
The prompt settings of `entityId` as this peer sees them, merged from its device and its Interactable.
| arg | type | description |
|---|---|---|
| entityId | string |
usable( ) → void
Every usable entity id this peer knows.
statusOf(entityId: string, peer: number) → any
What the prompt should say for `peer` right now: { label, hint, locked, available, state, needsCode, codeLength, busy }.
| arg | type | description |
|---|---|---|
| entityId | string | |
| peer | number |
setPromptStyle(style: string) → void
Set the prompt style every Interactable left on "default" uses: glyph, ring, tooltip, dot or pixel.
| arg | type | description |
|---|---|---|
| style | string |
promptStyle( ) → string return kitSettings
setShowLabels(on: boolean) → void
Show or hide the text beside prompts.
| arg | type | description |
|---|---|---|
| on | boolean |
showLabels( ) → boolean return kitSettings
inReach(peer: number, entityId: string) → void
| arg | type | description |
|---|---|---|
| peer | number | |
| entityId | string |
holderBlocks(entityId: string, peer: number) → boolean
| arg | type | description |
|---|---|---|
| entityId | string | |
| peer | number |
setHolder(entityId: string, peer: number) → void
| arg | type | description |
|---|---|---|
| entityId | string | |
| peer | number |
decide(peer: number, entityId: string, verb: string, args: any) → void
| arg | type | description |
|---|---|---|
| peer | number | |
| entityId | string | |
| verb | string | |
| args | any |
_install( ) → void
A hot reload can re-run this module while interactKit.net keeps the handler of the copy before it. Every registration re-installs this copy's handler and event sink, so the registry the components fill is always the one requests are decided against.
resolve(target: any) → string
Resolve a wiring target (entity, id or name) to an entity id.
| arg | type | description |
|---|---|---|
| target | any |
fire(sourceId: string, targets: any, action: string?, on: boolean, peer: number?) → void
Send `action` to every target ("follow" opens on `on` and closes on off; "invert" the reverse). Runs on the owner of the source.
| arg | type | description |
|---|---|---|
| sourceId | string | |
| targets | any | |
| action | string? | |
| on | boolean | |
| peer | number? |
signal(target: any, action: string, cb: any?) → void
Tell a device to `action` (open, close, toggle, unlock, lock) as wiring would.
| arg | type | description |
|---|---|---|
| target | any | |
| action | string | |
| cb | any? |
use(target: any, args: any?, cb: any?) → void
Use `target` as the local player would (scripts, tests, cutscenes). args: { code, expect, scripted }.
| arg | type | description |
|---|---|---|
| target | any | |
| args | any? | |
| cb | any? |
_tickOwner( ) → void
Owner housekeeping: let go of holds whose player stopped refreshing them.
components( ) → any
component(name: string) → any
The component type of one of interactKit's components, by short name ("Door", "Switch", "Lock", ...): pass it to component.add / get / has. Works wherever interactKit is installed.
| arg | type | description |
|---|---|---|
| name | string |
catalog(filter: any?) → void
Every kind with tags: catalog({ family = "door", tag = "scifi" }).
| arg | type | description |
|---|---|---|
| filter | any? |
kinds(family: string) → void
| arg | type | description |
|---|---|---|
| family | string |
tags( ) → void
spawn(id: string, pos: { number }, opts: any?) → any
Spawn a ready-made thing: spawn("door.airlock", {0,0,5}, { look = "scifi", yaw = 90, name = "Hatch", synced = true, fields = {...}, lock = {...}, interact = {...} }).
| arg | type | description |
|---|---|---|
| id | string | |
| pos | { number } | |
| opts | any? |
_spawnItem(pos: { number }, fields: any, opts: any?) → any
an Item on its own entity (spawnKey, container loot)
| arg | type | description |
|---|---|---|
| pos | { number } | |
| fields | any | |
| opts | any? |
spawnKey(pos: { number }, opts: any?) → any
Spawn a key or keycard players pick up by walking over it, counted per player in interactKit's own inventory. opts: { kind = "key" | "keycard", color = "red" (keycards), look = "wood" | "scifi" | "cartoon", perPlayer = true, respawn = false, respawnTime, name, synced = true }. Returns the entity (it carries an interactKit.Item).
| arg | type | description |
|---|---|---|
| pos | { number } | |
| opts | any? |
_ensureInventory( ) → void
In play, make sure the shared inventory exists: the host (or a peer alone) spawns it once; everyone else receives it.
ensureHud( ) → void
Make sure this peer has its prompt HUD (spawned by the first usable thing in play).
_settings( ) → any return kitSettings end
Settings shared with the HUD.
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.