Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

README.md

scene_build

Turns builder code into scene records, and scene records into scene entities.

run(builder) opens an entity capture scope, calls builder, and composes every entity it created into records — then despawns them. The builder writes ordinary spawn code; what comes back is data. A builder that raises leaves nothing behind.

What a component the builder attached creates while running its own lifecycle belongs to that component: the record names the COMPONENT, and the same lifecycle runs again wherever the record is put back. That is what makes a nested build one build — a placement the builder makes runs its own module and owns what it lands, and the build around it describes the placement.

reconcile(records, target, owner) applies records to the scene under target, writing owner and the record's place in the hierarchy onto each entity it places as the buildOwner / buildKey attributes. A rebuild reads that pair back off the entities under target and lands on the same ones, so nothing has to be remembered between two rebuilds — the pair is in the scene, and a reload brings it back with the entity. It returns the ids it landed on, keyed by record identity.

A record is identified by its place in the hierarchy — the chain of names from the build root down to it, base/coin_3 — so dropping a line from the middle of a builder, inserting one, or emitting two entities in the other order leaves every other entity's id where it was. Children of one parent that share a name carry their rank among those, base/crate#2, counted in the order the builder created them.

Together these are the bake: code in, durable static-id scene content out.

Who states an entity

An entity names the build that placed it, so ownerOf(id) answers which build owns it — and answers nil for an entity an author spawned. sourceOf(owner) names the file that build is written in, from the source the reconcile running it passed.

That pair is what makes ownership legible where an author meets it. A build states its entities in full every time it runs, so a value set on one of them holds until the next run. notePreview(id, values) records what the entity carries after such a change and takePreview(id) reads it back exactly once — in the run that states the entity again, which is where what the author set and what the build says can be named side by side.