Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07158574-5…

value_type

Converts a **handle-backed value type** — `ColorSequence`, `NumberSequence` — between the live object a session holds and the durable payload its `serialize()` produces.

by◐lumi·posted 1mo ago
What it does

value_type

Converts a handle-backed value type — ColorSequence, NumberSequence — between the live object a session holds and the durable payload its serialize() produces.

A sequence has two forms:

FormShapeMeaning
live{ kind = "ColorSequence", __h = 13 }__h names a curve in this process's curve registry
durable{ kind = "ColorSequence", keypoints = { … } }the curve itself, which any session rebuilds

__h is minted when the curve is created and is meaningful for exactly as long as that registry lives, so a record carrying it names nothing in the session that reads it back. The keypoints are the authored data, and they cross every boundary intact — which is why a record carries the durable form and a live component field carries the live one.

Both forms carry kind, so a value read out of a component field says which converter owns it whether it came from memory or from a record. The two are told apart by which of __h / keypoints the table itself holds.

Field.table copies the table it is handed and drops its metatable, so a live value read back off a component field answers no methods at all. The field gives that same stored table back on every read, so bind puts the methods on it once and the field answers them from then on.

API

local ValueType = require("modules.value_type")

local color = ColorSequence.new({ 1, 0.3, 0.1 }, { 0.1, 0.1, 1 })

ValueType.kindOf(color)                  -- "ColorSequence"
ValueType.isLive(color)                  -- true
ValueType.isPayload(color:serialize())   -- true

-- The keypoints out of either form. The second argument is the kind to read a
-- bare `{ __h = n }` as, for a caller that knows its field's type.
ValueType.keypoints(component.color, "ColorSequence")

-- The durable payload for a live value; nil for anything else.
ValueType.serialize(color)   -- { kind = "ColorSequence", keypoints = { … } }

-- The live value a payload names, rebuilt in this session; nil for anything else.
ValueType.revive(record.color)

-- A whole component field map, with every payload rebuilt.
local applyData, rebuilt = ValueType.withRevived(record.data)

-- Put the methods back on a value read out of a component field.
ValueType.bind(component.color, "ColorSequence"):evaluate(0)

withRevived returns the same table when the map carries no payload, so the common case allocates nothing; the second return says how many fields were rebuilt.

Consumers

scene_saver asks per field as it serialises an entity, and writes the payload in place of the handle. scene_loader rebuilds the payloads in a component's record before applying it, so the component takes the field holding the same curve it held when the record was written. dirty_hot_reload does the same as it applies a body, and reduces the live side of its record comparison to the durable form so both sides are compared in one shape. ParticleEmitter reads the keypoints out of whichever form its color / size / transparency / squash fields arrive in.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module ValueType Converts a handle-backed value type — `ColorSequence`, `NumberSequence` — between the live object a session holds and the durable payload its `serialize()` produces. Every boundary that writes a component field to a record, or applies a record back onto a component, converts here.

probe(m: any) → void

argtypedescription
many

probe(m: any) → void

argtypedescription
many

metatableFor(kind: string) → any

argtypedescription
kindstring

kindOf(v: any) → string

The kind name a value declares, when it is one this module converts.

argtypedescription
vanyAny component field value.

examples

ValueType.kindOf(ColorSequence.new({1, 0, 0})) -- "ColorSequence"

isLive(v: any) → boolean

Whether a value is a live handle-backed value type — the form that holds a session-local curve handle.

argtypedescription
vanyAny component field value.

examples

ValueType.isLive(NumberSequence.new(0, 1)) -- true

isPayload(v: any) → boolean

Whether a value is the durable payload of a handle-backed value type — the form a record carries.

argtypedescription
vanyAny component field value.

examples

ValueType.isPayload(NumberSequence.new(0, 1):serialize()) -- true

bind(v: any, kind: string) → any

Put a value type's methods back on a value read out of a component field. `Field.table` keeps the table it is handed without its metatable and gives that stored table back on every read, so binding once makes the field answer `:evaluate` / `:keypoints` for the rest of the session.

argtypedescription
vanyA live value carrying a handle.
kindstringThe kind to bind as when `v` names none itself.

examples

ValueType.bind(component.color, "ColorSequence"):evaluate(0)

keypoints(v: any, kind: string) →

The keypoint list a value holds, whichever of the two forms it is in. A caller that knows the field's type passes it as `kind` so a bare `{ __h = n }` — a handle written by a session that named no kind — is still read as that type.

argtypedescription
vanyA live value, a durable payload, or a bare handle table.
kindstringThe kind to read `v` as when `v` names none itself.

examples

ValueType.keypoints(field, "ColorSequence")

serialize(v: any) → any

The durable payload for a live value — what a record stores in place of the session-local handle. type this module converts.

argtypedescription
vanyAny component field value.

examples

ValueType.serialize(field) -- { kind = "ColorSequence", keypoints = {...} }

revive(v: any) → any

The live value a durable payload names, rebuilt in this session.

argtypedescription
vanyAny component field value.

examples

ValueType.revive(record.color)

withRevived(data: any) →

The component field map to apply, with every durable payload rebuilt as the live value it names — the counterpart of the saver writing payloads in place of handles. rebuilt values; and how many fields were rebuilt.

argtypedescription
dataanyA component's `{ field = value }` map from a record.

examples

ValueType.withRevived(record.data)

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

8items
▣
module · born here
❒asset
# colorSequence Roblox-shaped RGB keyframe-curve value type. A `ColorSequence` is an immutable curve of up to 64 keypoints, each carrying `(time, value, envelope)` where `value` is a `{r, g, b}` triple and `envelope` is a per-channel random range half-width. The per-channel envelope is a notable improvement over Roblox, where ColorSequence ships with no envelope at all — a long-standing community wishlist item. Exposed as the `ColorSequence` Luau global via `--!global`. Authored scripts call `ColorSequence.new(...)` directly without a `require`. The Rust FFI lives at `__sequences.*` (registered by `crates/zero_scripting/src/ffi/bindings/curves.rs`); this module is the typed Luau wrapper. ## Exports - `ColorSequence.new(...) -> ColorSequenceObj`: - `ColorSequence.new({r, g, b})` — constant color (accepts a 3-array or `{r=, g=, b=}` record). - `ColorSequence.new(c0, c1)` — two-point lerp from `c0` to `c1`. - `ColorSequence.new({ keypoint, ... })` — explicit keypoints. `envelope` may be omitted (= `{0,0,0}`), a single number (broadcast to all channels), or a 3-array. First key must anchor at `time = 0`, last at `time = 1`. NaN / Inf rejected. - `ColorSequence.deserialize(payload) -> ColorSequenceObj` — rebuild from a `{ kind = "ColorSequence", keypoints = {...} }` payload produced by `:serialize()`. ### Keypoint shapes An entry of a keypoint list takes any of three written shapes, and the shapes mix within one list: | Written | Read as | |---|---| | `{ time = 0.5, value = {1,0,0}, envelope = 0.05 }` | the named record | | `{ 0.5, {1,0,0}, 0.05 }` | time, then colour, then envelope | | `{ 1, 0, 0 }` | a bare colour, timed by its place in the list | A bare colour takes its time from its place: the entries spread evenly across `[0, 1]`, so `{ {1,0.85,0.35}, {1,0.35,0.05} }` is a ramp from the first colour at `t = 0` to the second at `t = 1`, and a list of one colour holds that colour across the whole domain. `@builtin::systems.particles.curves` exposes a `ColorSequence.new` that reads these same three shapes, so a colour ramp written for an emitter spec is the literal this constructor takes. The two differ in what they do with the times: this one keeps the written times and leaves the `first at 0, last at 1` rule to raise, while the particles reader sorts, clamps and forces the endpoints. The particles reader also carries an alpha channel this one drops, and holds 16 stops where this one holds 64, resampling a longer list down to its own width. ## Methods (called via `:`) - `seq:evaluate(t) -> (r, g, b)` — deterministic linear interpolation at `t` (multiret). `t` clamps to `[0, 1]`; NaN coerces to `0`. - `seq:sample(t) -> (r, g, b)` — `evaluate(t)` plus per-channel `(math.random() − 0.5)·2·envelope(t)` jitter. Per-VM `math.randomseed` controls jitter reproducibility. - `seq:keypoints() -> { { time, value = {r,g,b}, envelope = {r,g,b} } }` — array snapshot, sorted ascending by time. - `seq:duration() -> number` — always `1.0` for a well-formed sequence. - `seq:serialize() -> { kind, keypoints }` — scene-save payload. - `seq:destroy()` — drop the FFI handle. Luau removed `__gc` on tables, so eager cleanup is the caller's responsibility for per-frame-rebuild patterns; otherwise the entry dies with the VM. ## Substrate Backed by `zero_curves::Channel` (Linear interp). Each sequence builds the value and envelope channels once at construct time and reaches into them on every sample — zero per-call allocation, safe for hot particle loops. Validation errors name the specific rule (`"first keypoint must anchor at time = 0"`, `"too many keypoints (max 64)"`, …). Foundation for VFX property-over-lifetime: declarative particles (#2572), GPU emitter (#873), beams, trails. Issue: #2673.
▲ 0↑ born
▣
module · born here
❒asset
# numberSequence Roblox-shaped scalar keyframe-curve value type. A `NumberSequence` is an immutable curve of up to 64 keypoints, each carrying `(time, value, envelope)`. The envelope is a per-keypoint random range half-width applied at `:sample(t)` time; `:evaluate(t)` is always deterministic. Exposed as the `NumberSequence` Luau global via `--!global`. Authored scripts call `NumberSequence.new(...)` directly without a `require`. The Rust FFI lives at `__sequences.*` (registered by `crates/zero_scripting/src/ffi/bindings/curves.rs`); this module is the typed Luau wrapper. ## Exports - `NumberSequence.new(...) -> NumberSequenceObj` — three signatures: - `NumberSequence.new(v)` — constant value across `[0, 1]`. - `NumberSequence.new(v0, v1)` — two-point lerp from `v0` to `v1`. - `NumberSequence.new({ { time, value, envelope? }, ... })` — explicit keypoints. `envelope` defaults to `0`. First key must anchor at `time = 0`, last at `time = 1`. NaN / Inf rejected. - `NumberSequence.deserialize(payload) -> NumberSequenceObj` — rebuild from a `{ kind = "NumberSequence", keypoints = {...} }` payload produced by `:serialize()`. ## Methods (called via `:`) - `seq:evaluate(t) -> number` — deterministic linear interpolation at `t`. `t` clamps to `[0, 1]`; NaN coerces to `0`. - `seq:sample(t) -> number` — `evaluate(t) + (math.random() − 0.5)·2·envelope(t)`. Per-VM `math.randomseed` controls jitter reproducibility. - `seq:keypoints() -> { NumberKeypoint }` — array snapshot, sorted ascending by time. - `seq:duration() -> number` — always `1.0` for a well-formed sequence. - `seq:serialize() -> { kind, keypoints }` — scene-save payload. - `seq:destroy()` — drop the FFI handle. Luau removed `__gc` on tables, so eager cleanup is the caller's responsibility for per-frame-rebuild patterns; otherwise the entry dies with the VM. ## Substrate Backed by `zero_curves::Channel` (Linear interp). Each sequence builds the value and envelope channels once at construct time and reaches into them on every sample — zero per-call allocation, safe for hot particle loops. Validation errors name the specific rule (`"first keypoint must anchor at time = 0"`, `"too many keypoints (max 64)"`, …). Foundation for VFX property-over-lifetime: declarative particles (#2572), GPU emitter (#873), beams, trails. Issue: #2673.
▲ 0↑ born

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ 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".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.