now( ) → number
The shared session clock (seconds), the same on every peer of a session.
online( ) → boolean
Whether the multiplayer relay is connected.
isHost( ) → boolean
Whether this peer is the host (true offline).
owns(e: any) → boolean
Whether this peer owns (simulates) an entity. Offline every entity is ours; an entity no peer owns belongs to the host.
vec(v: any, fallback: Vec?) → Vec
Any position form ({x,y,z}, {x=,y=,z=}, a vector, a transform proxy) as {x, y, z}.
| arg | type | description |
|---|
| v | any | |
| fallback | Vec? | |
cross(a: Vec, b: Vec) → Vec
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
frame(area: any) → Frame
Turn an area description ({ center, width, height, depth, down, across? }) into a frame with unit axes.
| arg | type | description |
|---|
| area | any | |
toWorld(f: Frame, x: number, y: number, z: number) → Vec
Area-local metres (X across from centre, Y up from centre, Z depth) to a world point.
| arg | type | description |
|---|
| f | Frame | |
| x | number | |
| y | number | |
| z | number | |
toWorldDir(f: Frame, x: number, y: number, z: number) → Vec
An area-local offset (no centre) to a world offset.
| arg | type | description |
|---|
| f | Frame | |
| x | number | |
| y | number | |
| z | number | |
packFrame(f: Frame) → void
A frame as a plain synced table (what each object carries).
unpackFrame(t: any) → Frame
A packed frame back into a Frame (tolerates a missing or partial one).
qaxis(axis: Vec, angle: number) → void
A rotation of `angle` radians about a unit axis, as {x, y, z, w}.
| arg | type | description |
|---|
| axis | Vec | |
| angle | number | |
qmul(a: { number }, b: { number }) → void
Product of two quaternions (a then b applied: a * b).
| arg | type | description |
|---|
| a | { number } | |
| b | { number } | |
qfromUp(dir: Vec) → void
The rotation that turns +Y onto a unit direction.
defineKind(name: string, def: any) → KindDef
Register (or replace) a kind on this peer.
| arg | type | description |
|---|
| name | string | |
| def | any | |
kind(name: string) → KindDef
A kind's definition, or nil.
| arg | type | description |
|---|
| name | string | |
on(name: string, fn: (...any) → void
Listen to an event on this peer; returns a connection with :Disconnect().
| arg | type | description |
|---|
| name | string | |
| fn | (...any | |
Disconnect(self: any) → void
| arg | type | description |
|---|
| self | any | |
emit(name: string, ev: any) → void
Fire an event on this peer (the kit's components call this).
| arg | type | description |
|---|
| name | string | |
| ev | any | |
registerObject(id: string, pub: any) → void
| arg | type | description |
|---|
| id | string | |
| pub | any | |
registerDirector(id: string, pub: any) → void
| arg | type | description |
|---|
| id | string | |
| pub | any | |
objects( ) → void
Every live object's component table on this peer, keyed by entity id (dead ones dropped).
directors( ) → void
Every director's component table on this peer, keyed by entity id.
hash(seed: number, i: number) → number
A deterministic number in [0, 1) from a seed and an index (the same on every peer).
| arg | type | description |
|---|
| seed | number | |
| i | number | |