rng(seed: number?) → Rng
A seeded random stream. Same seed, same numbers, on every machine.
| arg | type | description |
|---|
| seed | number? | Any whole number; 0 is replaced by a fixed non-zero seed. |
examples
local r = U.rng(42); print(U.rand(r))
rand(r: Rng) → number
The next number in [0, 1) from a seeded stream.
| arg | type | description |
|---|
| r | Rng | The stream from `M.rng`. |
range(r: Rng, lo: number, hi: number) → number
A number between lo and hi from a seeded stream.
| arg | type | description |
|---|
| r | Rng | |
| lo | number | |
| hi | number | |
vec(v: any) → Vec
Any position form ({x,y,z}, {x=,y=,z=}, a vector, an entity) as a plain {x, y, z} array.
add(a: Vec, b: Vec) → Vec return
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
sub(a: Vec, b: Vec) → Vec return
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
scale(a: Vec, k: number) → Vec return
| arg | type | description |
|---|
| a | Vec | |
| k | number | |
lerp(a: Vec, b: Vec, t: number) → Vec
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
| t | number | |
len(a: Vec) → number return math
flatDist(a: Vec, b: Vec) → number
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
faceQuat(from: Vec, to: Vec) → void
A yaw-only quaternion {x, y, z, w} that faces from `from` towards `to` on the ground plane.
| arg | type | description |
|---|
| from | Vec | |
| to | Vec | |
online( ) → boolean
Whether the multiplayer relay is connected.
owns(e: any) → boolean
Whether this peer owns (simulates) an entity. Offline, every entity is ours. An entity no peer owns yet (owner 0, a claim the relay has not confirmed) belongs to the host, so exactly one peer acts on it.
peerId( ) → number
This peer's id, 0 offline.
playerBodies( ) →
Every player's body (avatar) entity on this peer, sorted by id so every peer agrees on the order.
registerSpawner(id: string, comp: any?) → void
A Spawner adds itself when it wakes and removes itself when it goes.
| arg | type | description |
|---|
| id | string | |
| comp | any? | |
spawners( ) → void
Every registered Spawner as { id, name, comp, ent }, sorted by name. Cheap: no world scan.
registerPoint(id: string, comp: any?) → void
A SpawnPoint adds itself when it wakes and removes itself when it goes.
| arg | type | description |
|---|
| id | string | |
| comp | any? | |
points( ) → void
Every registered spawn point as { id, comp }, sorted by entity name then id.
splitList(s: string?) → void
Split "a, b,c" into { "a", "b", "c" }; an empty string gives {}.
| arg | type | description |
|---|
| s | string? | |