builder
What a graph builder hands the author, in the call form: `proc.define(function(g) ... end)`.
proc.builder
What a graph builder hands the author, in the call form: proc.define(function(g) ... end).
g.<name>(args)adds a node of the node asset the name resolves to, by asset identity: the nodebox and the node's folder name (g.points.disc), a path (g["/zero/source/fx/ring.procNode"]),~(the nearest package, effect or world root:g["~/ring"]), a guid, or a short name (g.disc). A path,~name or identity ending in.procNodeor.procGraphnames an asset of that kind alone; one without the suffix names either, so where a node and a part share a name it states the suffix. A name that matches two nodes, and a name that matches none, are errors that name the candidates. Each call is recorded in the graph by the node's guid. Arguments are a table naming inputs or positional values in the node's input order.- What a call answers: a node with one output answers that output's socket, a node with several answers a
record of sockets by output name (
local f = g.core.normals.face(geo); f.geometry, f.area), a node with none answers nothing. The record does not depend on declaration order. The record handed whole to an input that takes one value is refused where it is handed, naming the outputs to read (.value,.report). - A name is called this way only for a node written in the call form (
builder.callsByName(path)says which). A name no node answers to is refused naming the nearest names a call resolves. - A node's own source reaches its package's modules and assets with
require("~.<name>")andasset.resolve("~.<name>", type):~there is the nearest.packagefolder, wherever the node sits in it. g.op.<name>(args)(andproc.op.<name>) adds a node of an op, for library nodes built on the ops. An op that is a graph built withg:node(theprocNodes/of the procgen package, registered under their graph ids) is refused at the call, naming its folder and the node written in this form that answers to the same name ('g.op.points.filter' is .../procNodes/pointsFilter.procNode, a graph built with g:node, ...; call g.points.filter). An id no op carries is refused naming the ops that start the same way.g:input(name, default, opts)is typed by the default:Float,String,Bool,Vec3,Color,List<T>,Recordwith its fields.optstakesmin,max,options,description,optional,plainandtypefor a default that does not state its type or no default at all. An empty table default with a statedtypeis that type's empty value (g:input("entities", {}, { type = "List<Entity>" })). A vector written as a plain table reads its components by name whichever form it was written in, the reading an op's params take:{ 0, 0, 0, 1 }answers.w, and a pair ({ a, b },{ x, y }or{ x, z }) answers its second component as.yand as.z.- An input declared
plain = true, an input withoptions, and an input of type Bool or String is a plain value while the graph is built:g:inputanswers the value itself,if, comparisons and loops over it are allowed, and it passes into calls as a constant.plain = trueis how a count, a vector, a record or a list that chooses the graph's structure is declared (g:input("storeys", 5, { type = "Int", plain = true }),g:input("edges", { { bays = 3 } }, { plain = true })): the graph is built again for each value it is given, it is not animated, and it takes no per-element field. Any other number and vector input is a socket, which changes without a build and takes animated values and fields. A table value reaches the build as a frozen copy. The graph records the plain values it was built with ingraph.plain, and each such declaration ingraph.inputs[name].plain = true. - Sockets take
+ - * / % ^ // ..and unary minus,math.*andvector.*(each amath.<name>node;vector.createover sockets ismath.vec2,math.vec3ormath.vec4by its component count),x.name,x.name = vandx[name] = vfor a computed name (which rebindx),x[class][name],x[n], andfor index, item in list do ... end. A source loaded throughbuilder.prepareSourcereads plainmath,vectorandrandover sockets unchanged;defineloads a node or graph entry that way when it names them. vector.createhas the width of its component count whether its arguments are sockets or numbers: two numbers answer the Vec2 value{ x, y }and four the Vec4 value{ x, y, z, w }(whatmath.vec2andmath.vec4make of numbers), and three a Luau vector.orient = vector.create(0, 0, 0, 1)writes a Vec4 column.g.compare(a, op, b),g.where(cond, a, b),g.pick(choice, alternatives),g:fold(n, init, fn, opts),g:state(name, columns),g:step(dt, substeps, fn),g:check(cond, message),g.has(geometry, class, name)andg.copy(socket)record the constructs the evaluator knows.g:state(name, columns)states the columns a step keeps,{ [name] = { type, count } }, as values the plan knows: literals and inputs, records and lists of them, and what constructs and apureio.luaucall make from them. A pure call's answer stands even when its arguments are cooked (a call reading the attribute names of a source's points), so aforover its answer may add a column per name (schema["s_" .. name] = specs[name]overspecs.keys), and a step body writes them by the same names.g:check(cond, message): acondknown while the graph is built refuses the build with the message (a true one records nothing); acondthat reads a socket is recorded for the plan or the cook to answer. The build of a node's own defaults, which is what indexes the node, holds such a refusal instead of raising it (graph.refusals), andforInputsstates it where the node is called or cooked as it stands, so a check over a plain input fires when the call gives it the refused value.- A plain Luau table filled inside a
forbody over sockets keeps one element (rings[#rings + 1] = v,table.insert(rings, v)): the body is one pass for every item.builder.checkrefuses it with the codesocket-loop-append, naming the form to write: a local declared before the loop and assigned inside it, read after the loop, where it is the list of every pass's value. g.copy(value)of a record or a list written in the graph (g.copy({ total = 0 })) is a value of its own that member writes rebind, so aforbody that fills it carries it from pass to pass.- A class view made with a socket key (
names[i]) and read as a value is a node of the scope it was made in, whichever loop body first reads it. - A
forbody is one pass that stands for every item.indexis the item's place (a socket, from 1). A value built outside the body that the body reads or assigns (geometry[class][name] = v,record.name = v,record[name] = v) is carried: each pass starts from what the pass before left, the first from the value as it stood before the loop, and after the loop the value is what the last pass left. The loop records the carries inscope.carries[id] = { init, result }and the refsloop_index,loop_carry(the value at the start of a pass) andloop_result(the value after the loop). A value the body only reads reads as it was. The emitter writes a carrying loop as it was authored: a local that starts asg:copy(value), the body's assignments to it, and the loop reading that local after it (proc.emit). g.clock.placement(16 numbers, column after column),g.clock.inverse,g.clock.rotation({ x, y, z, w }) andg.clock.entityanswer where the graph stands in the scene it is cooked in: each is aconstruct.scenenode that reads the scene the cook is handed (a graph standing on no entity has the identity placement and no entity).g.transform.point(p),g.transform.direction(d)andg.transform.rotation(q)carry a world position, direction or quaternion into the graph's space through the inverse placement; each takes plain values, sockets or Fields.g:fold(n, init, fn, { stop = "changed" })or{ stop = function(before, after) return <Bool> end };fnreturns the state only. The fold runsnpasses and ends early at the first pass whose stop holds.g.elementis the element a Field evaluates over:g.element.id(Int),g.element.P(the position leaf thatfieldc.withPositionsubstitutes, also writteng.element.point.P) andg.element.<class>.<column>for a column of the domain the field stands in. Each read is a socket, sog.element.id * 1.0is a math node.rand.unit(seed, ...scope, id)(a global in a node source, alsobuilder.rand.unit) is the Float field of unit draws keyed by the seed, the scope (graphId, nodeId, channel, orgraphId, compositePath, nodeId, channel) and the elementid, last (g.element.id). It adds anio.luaunode{ module = "@builtin::systems.procgen.proc.fieldc.leaves", fn = "rand", args = { seed, { ...scope }, id }, returns = { "Any" } }and answers itsvalue.geometry.names[class]lists the attribute names a class holds (a list socket the plan answers);geometry[class].count = nassigns the domain count, socountis no column's name (a value per element written under it is refused);geometry.material = massigns the material.namesis read by that name on any socket: what is read off it by a class (geometry.names.point) lists the names, and any other read (record.names[2],record.names) is the member a record holds under that name, ascountandkeysare.materialis assigned by that name on any socket.- A member, an item, a column or the names of a value built outside a fold, step or stop body that the body reads first is a node of the scope the value was built in: the body and every later fold read the one value, which the plan writes once. A read keyed by a socket of the body (a fold's index) stays in the body.
g.clock.time,.frame,.deltaand.durationare sockets;.fps,.frames,.loopand.realTimeare the timeline's values.- Luau's
< <= > >= == ~=over a socket, andand,or,not,ifandwhilethat test one, have no value while the graph is built.builder.check(source)names each one with theg.*form to write, anddefineholds a node or graph entry to it.andandortest their left operand alone, soplain or socketpasses. The check follows names block by block as Luau scopes them: a local, a loop variable or a function parameter is its block's own, and a parameter of a function that is not a fold, step or stop body is not known to be a socket (a comparison over one is refused when the graph is built). Plain inputs are not sockets to the check. A plain Luau table indexed by a socket (LANES[values.type]) answers nil while the graph is built, so the check refuses it with the codesocket-table-index, which namesg.pick. - A list of values holds a nil as a value:
{ a, nil, b }is three, and the second is a constant of nothing.
Building a graph for other plain values
A graph whose plain inputs change structure is built again for the values a cook was given.
builder.forInputs(graph, inputs)answersgraphwhile its plain inputs hold what the build used, else the graph built again fromgraph.sourcewith the valuesinputsstates (an input it leaves out takes its default); values are compared by content, a record or a list included, and the result is cached by the source text and the values, so a node written again is built again.builder.KEPT_BUILDS_PER_SOURCEof a source's builds are kept, the ones used last. A build for other values keeps what the cook already made: only the nodes the new values change cook. A plain input given an animated value, a per-element field or a value held on the device is refused by name. It answersnil, reasonwhen the source cannot be built again or a value is outside the input's options.- An optional input with no default (
g:input(name, nil, { optional = true })) is nil while the graph is built for a call that leaves it unwired, and its socket otherwise, soif input == nil then ... endin a node source is decided by what the call wired. The declaration stateswiring = trueand the graph records the wiring it was built for ingraph.wiring[name];forInputsbuilds the graph again for a cook given no value for such an input (values[name] == falsestates none inrebuildandwithInputs). builder.rebuild(graph, values)builds again unconditionally;builder.withInputs(values, fn)runs a function that callsproc.defineand gives that graph the values. A node asset called with a plain value records it as a constant param; the evaluator reads a node's graph throughforInputswith those params.
What a build resolves once
A build resolves each name once. The first call of a name g.<name>(...) in a build finds the node asset the name
answers to; the build keeps the asset, its inputs and outputs, and the envelope its calls record, and every later call
of that name in the same build takes them. Each building frame (a graph source, or a node source loaded by a call)
holds its own, by the graph's source and the name, on the thread that runs the build; the memo ends with the frame, so a
node written between two builds is resolved again by the next, and builds on other threads share nothing. The Info of
a node asset is kept by the node graph it was read from, and the line of each call is kept as a number that siteOf
states as path:line where it is read. builder.setResolveMemo(false) switches all three off for the builds after
(the answer is the setting before), and builder.resolveCounts() answers the calls that resolved a name (resolved)
and the calls a kept answer served (hits).
What a build is made against
A graph source that has a base is built against it. The base of an entry source is the graph the last
proc.takeHandOff of its folder gave a Generator (builder.setBase(graph), builder.baseOf(entry)), held weakly.
When the run of a build ends, a pass compares every node the run made with the base's node of the same id (compareNode
of proc.eval.replan, and the node's op field by field). A node that is equal is replaced in graph.nodes by the
base's own table, which is frozen, along with the tables under its inputs and params; a node that differs, or that the
base does not hold, is frozen where it is. The scopes are compared and the ones that differ are listed; they stay the
build's own tables. The graph states the result in _diff: changed (the ids of the nodes that differ or are new),
removed (the ids of the base's nodes the build did not make), scopes (the ids of the scopes that differ), added,
the counts of the nodes and scopes, against (the base, held weakly) and the edit counts of both graphs when the pass
ran. The planner (replan.dirty) reads it while the graph and the base stand as they did then, and compares only the
nodes it lists.
- A node that keeps the base's table keeps the place the base gave it in the order the nodes were made in. When this
build made it elsewhere, the graph states the new place in
_moved;builder.seqOf(graph, id)answers the place a node holds, andgraph:toJSON()states the nodes with it (builder.documentNode(graph, id, node)is one node as the document states it), so a document and an emitted source are those of a build that made every node itself. - A table two graphs share is frozen, so a write into one raises.
proc.editreplaces a node it writes into by a copy of its own (the node, itsinputsand itsparams) before it writes, andbuilder.againstCounts()counts those copies beside the passes run (passes), the nodes filed from the base (reused), the nodes listed (changed) and the time the passes took (ms). builder.setBuildAgainstBase(false)switches the pass off for the builds after (the answer is the setting before). A build of a source with no base, a build for other plain values (forInputs,rebuild) and a build of a node asset are the graph their run made.
What a build reads
A node or graph source is compiled with builder.compile(src, "@" .. entry) and run as a build with
builder.building(entry, fn, ...). While a build runs, the source sees a vfs whose read, readAsync and
readBounded note each file for that build, and builder.read (proc.read) notes a file read from a module the
build calls into. When the build ends, the files it read are recorded against its entry source, replacing what its
earlier builds read: builder.readsOf(entry) lists them and builder.readersOf(file) the entry sources whose last
build read a file. A write of such a file is a proc.sourceChanged of each of those sources. builder.forget(folder)
drops the source text and the built graph the builder holds for a node or graph, so the next build that reaches it
runs its source again. The modules a build requires are recorded by the engine, which tells the node or graph type
through onDependencyChange when one of them re-runs.
The wiring of each run of graph.module
graph.module binds its wiring into the builder (builder.bind) each time its body runs, with the metatable of the
graphs that run makes as helpers.graph, and the builder keeps that wiring on the metatable. A graph is wired by the
run that made it: builder.run declares its outputs, a value is wired into its refs, and rebuild builds an inline
graph again, each through the wiring of the graph's own run. The body runs again whenever the require cache lets go of
the module while a module that took its functions keeps them (proc.define is graph.module's define as proc
loaded it), as a reset of the scripting state to a mark taken before the module loaded does; the graphs of both runs
are then built side by side.
What a graph records
A call-form graph states surface = "call". Each node it makes carries call = true, seq (the order it was made
in, which the emitter writes it back in) and scope. A node asset is op = { __ref, type = "procNode", name }; an
op is its id string; a construct is op = "construct.<kind>" with construct = <kind>. graph.scopes holds each
for, fold, stop and step body, graph.states each g:state, graph.plain the plain input values.
Each call and scope also records the line of the graph's source it was written on, path:line
(builder.siteOf(graph, id)), in a table the graph's document leaves out, so where a call sits moves no hash. The
plan carries it onto each call it writes out (plan.flat.origins[<flat id>].site, the graph's own calls in
plan.flat.sites), and a cook's failure is read at it: describeFailure(flat, err) of the eval module
(@builtin::systems.procgen.proc.eval) answers
<path>:<line>: g.<call> failed: <why>, the line being in the deepest source the person can edit.
The inputs of a construct node are refs (a constant is { kind = "const", value }); params are constants.
| construct | inputs | params | answers |
|---|---|---|---|
member | value, name | the member of value | |
member_set | value, name, to | value with the member written | |
item | list, index | the item | |
column | geometry, class, name | the column read (a read of count is the domain count) | |
column_set | geometry, class, name, value | the geometry with the column written | |
column_remove | geometry, class, name | the geometry without the column | |
count_set | geometry, class, count | the geometry with that class's domain count set to count; a value per element is refused (no column is named count) | |
material_set | geometry, material | the geometry with its material set | |
names | geometry, class | the List of attribute names the class holds, answered at plan | |
has | geometry, class, name | a Bool answered at plan: whether the class holds the column | |
check | cond | message | nothing; a cond that is false when cooked is an error stating message |
compare | a, b | op (eq neq lt le gt ge) | a Bool |
where | cond, a, b | a where cond holds, else b | |
pick | choice, alternatives | the alternative the choice names: by option name, by a list position (a false choice the first, a true one the second), or by false and true keys | |
step_sample | step, value | the value of an animated value at the step's time | |
step_between | step, index | the fraction (0 to 1) of the step's movement that source index of the step has covered; the evaluator defines it |
A call that has several outputs names them in refs: { kind = "node_output", node, output = "<name>" }; a node with
one output has output = nil.
Refs
The v1 refs (const, graph_input, node_output, list, record, animated) and:
| ref | stands for |
|---|---|
loop_item { loop }, loop_collect { loop, ref } | the item of a for scope, and the list of ref over every item |
fold_value { scope }, fold_index { scope }, fold_result { scope } | the value and the index (from 1) of a fold pass, and the value after the last pass |
fold_before { scope }, fold_after { scope } | the state before and after a pass, inside a fold's stop function; scope is the stop scope |
step_state { scope }, step_index { scope }, step_result { scope } | the state record, the step record (dt time graphTime index first start, with step_sample and step_between), and the state the step reached |
state { name }, clock { field }, engine | declared state, the clock's field, the engine API namespace |
element { field, class? } | the element a Field evaluates over: field = "id" its index, field = "P" its position leaf (no class), else the column field of the domain class |
Scopes
graph.scopes[id] is { kind, parent, seq, ... }:
for:list,item.fold:count,init,result, andstopwhen it states one:"changed"(the pass ends the fold when the state it produced equals the one it read) or{ scope = <id of a stop scope> }.stop: a scope whoseparentis its fold. Its nodes readfold_beforeandfold_after;resultis the Bool ref the fold stops on. It is evaluated after each pass.step:dt,substeps,result.
The plain table of a graph and the plain = true flag of an input declaration state which inputs are build-time
values.
Part of @builtin::systems.procgen.proc.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2module proc.builder What a graph builder hands the author.
bind(helpers: any) → void
Bind the graph module's wiring functions. Called by `proc.graph` each time its chunk runs, with the metatable of the graphs that run makes as `helpers.graph`.
| arg | type | description |
|---|---|---|
| helpers | any |
helpersOf(graph: any) → any
The wiring of the run of `graph.module` that made `graph`; the run bound last for a table no run made.
| arg | type | description |
|---|---|---|
| graph | any |
warnOnce(map: { [string]: boolean }, key: string, message: string) → void
| arg | type | description |
|---|---|---|
| map | { [string]: boolean } | |
| key | string | |
| message | string |
fail(message: string, level: number?) → never
| arg | type | description |
|---|---|---|
| message | string | |
| level | number? |
sourceAt(file: string) → string
The text of the source file `file`, or nil when it cannot be read.
| arg | type | description |
|---|---|---|
| file | string |
runningKey( ) → any
The key of the builds the running code belongs to.
sourcePath(path: string) → string
The one spelling of a source path every record uses: the `/zero/source/` form.
| arg | type | description |
|---|---|---|
| path | string |
noteRead(path: any) → void
Note that the build running on this coroutine, if one is, read `path`.
| arg | type | description |
|---|---|---|
| path | any |
read(path: any, ...: any) → void
| arg | type | description |
|---|---|---|
| path | any | |
| ... | any |
readAsync(path: any, ...: any) → void
| arg | type | description |
|---|---|---|
| path | any | |
| ... | any |
readBounded(path: any, ...: any) → void
| arg | type | description |
|---|---|---|
| path | any | |
| ... | any |
compile(src: string, chunkName: string) →
Compile a node or graph entry source so that what it reads while it builds is a dependency of the build: the chunk sees a `vfs` whose `read`, `readAsync` and `readBounded` note each file for the build running them. Every other global is the one the chunk would see.
| arg | type | description |
|---|---|---|
| src | string | The text of a node or graph `init.luau`. |
| chunkName | string | The chunk name, `"@" .. <entry path>`. |
examples
local chunk, err = proc.builder.compile(src, "@" .. entry)
__newindex(_: any, key: any, value: any) → void
| arg | type | description |
|---|---|---|
| _ | any | |
| key | any | |
| value | any |
read(path: string) → string
Read a file while a node or graph builds, making it a dependency of that build: a later write of the file builds the node or graph again, and every Generator standing on it cooks again. The call for a module a build calls into, whose own `vfs` reads are its own; a node or graph source's own `vfs.read` is noted already. Outside a build it reads the file and notes nothing.
| arg | type | description |
|---|---|---|
| path | string | VFS path of the file. |
examples
local contract = proc.read("/zero/source/kits/Hudson/kit.json")recordReads(entry: string, files: { [string]: boolean }) → void
Record `files` as what the last build of `entry` read, replacing what its earlier builds read.
| arg | type | description |
|---|---|---|
| entry | string | |
| files | { [string]: boolean } |
building(entry: string, fn: (...any) →
Run `fn`, the build of the node or graph whose entry source is `entry`, and record every file it read (through a chunk `compile` made, or `read`) as what that source's build depends on. A build that raises records what it read before it raised: writing one of those files is a reason to try it again.
| arg | type | description |
|---|---|---|
| entry | string | The entry source's path (`.../<name>.procNode/init.luau` or `.../<name>.procGraph/init.luau`). |
| fn | (...any | The build. |
examples
local ok, graph = proc.builder.building(entry, chunk)
setResolveMemo(on: boolean) → boolean
Switch what a build keeps while it runs on or off for the builds after: the node asset each name resolved to, the `Info` of each node graph and the line each call was written on. Off, every call resolves its name again and a site is stated as its `path:line` text when the call is recorded.
| arg | type | description |
|---|---|---|
| on | boolean | Whether a build resolves each name once. |
examples
local was = proc.builder.setResolveMemo(false)
resolveCounts( ) →
What calls by name have done since the module loaded: the calls that resolved their name (`resolved`) and the calls that took the answer a build had kept for it (`hits`).
examples
local counts = proc.builder.resolveCounts()
readersOf(path: string) →
The entry sources whose last build read the file `path`.
| arg | type | description |
|---|---|---|
| path | string | VFS path of the file. |
examples
for _, entry in ipairs(proc.builder.readersOf("/zero/source/kits/Hudson/kit.json")) do print(entry) endreadsOf(entry: string) →
The files the last build of the entry source `entry` read.
| arg | type | description |
|---|---|---|
| entry | string | The entry source's path. |
examples
local files = proc.builder.readsOf("/zero/source/fx/spark.procNode/init.luau")bindingOf(v: any) → Binding
| arg | type | description |
|---|---|---|
| v | any |
isSocket(v: any) → boolean
Whether a value is a socket.
| arg | type | description |
|---|---|---|
| v | any |
topScope(graph: any) → string
| arg | type | description |
|---|---|---|
| graph | any |
newSocket(graph: any, ref: any?, view: any?) → any
| arg | type | description |
|---|---|---|
| graph | any | |
| ref | any? | |
| view | any? |
socket(graph: any, ref: any) → any
A socket standing for the InputRef `ref` of `graph`.
| arg | type | description |
|---|---|---|
| graph | any | |
| ref | any |
scopeActive(graph: any, id: string) → boolean
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string |
carryPath(b: Binding) → void
The `for` scopes opened since the value's own scope, outermost first; nil when the value is not carried (it was built in the scope in use, or a fold or step body lies between).
| arg | type | description |
|---|---|---|
| b | Binding |
inScopeOf(b: Binding, fn: () → void
Run `fn` with only the scopes open that were open when the socket `b` was made: a socket that stands for a value of a scope (a class view read as a value, made where it is first used) is a node of the scope it belongs to, whichever loop body it is first used in.
| arg | type | description |
|---|---|---|
| b | Binding | |
| fn | ( |
atOwnScope(b: Binding, fn: () → void
Run `fn` as the scope the value `b` belongs to when `b` was built outside a fold, step or stop body that reads it: what is derived from it (a member, a column, the names a class holds) is evaluated once where `b` stands, and every body and every later fold reads that one value. A value a `for` body carries keeps the body's scope, since each pass starts from what the pass before left.
| arg | type | description |
|---|---|---|
| b | Binding | |
| fn | ( |
ensureCarried(b: Binding) → void
| arg | type | description |
|---|---|---|
| b | Binding |
overwrite(dst: any, src: any) → void
| arg | type | description |
|---|---|---|
| dst | any | |
| src | any |
finishCarries(graph: any, id: string) → void
The end of a `for` body: what it assigned is a result of the loop, what it only read is as it was.
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string |
refOf(b: Binding) → any
The InputRef a socket records at the place it is used. A socket made inside a `for` body and read after it arrives as the list of every item's value.
| arg | type | description |
|---|---|---|
| b | Binding |
unwrapDeep(v: any, graph: any?, seen: { [any]: any }) → any
| arg | type | description |
|---|---|---|
| v | any | |
| graph | any? | |
| seen | { [any]: any } |
unwrap(v: any, graph: any?) → any
`v` with every socket inside it replaced by the InputRef it records.
| arg | type | description |
|---|---|---|
| v | any | |
| graph | any? |
topGraph( ) → any
The graph the running thread is building, or nil.
pushGraph(key: any, graph: any) → void
Make `graph` the one the thread `key` builds into.
| arg | type | description |
|---|---|---|
| key | any | |
| graph | any |
popGraph(key: any) → void
Let go of the graph on top of the list of the thread `key`, and of the list itself once it is empty.
| arg | type | description |
|---|---|---|
| key | any |
graphOfValues(...: any) → any
| arg | type | description |
|---|---|---|
| ... | any |
current( ) → any
Current builder
freeId(graph: any, base: string) → string
Recording
| arg | type | description |
|---|---|---|
| graph | any | |
| base | string |
nextSeq(graph: any) → number
| arg | type | description |
|---|---|---|
| graph | any |
noteSite(graph: any, id: string) → void
The line of the graph's own source a call being recorded was written on: the innermost frame of the call stack that runs in that source. Nil for a graph built outside a source file. Kept in the graph's `_sites`, a table the graph's document leaves out, so where a call sits moves no hash and cooks nothing again. The table holds the line number, and `siteOf` states it as `path:line` where it is read (with the memo switched off it holds the text).
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string |
siteOf(graph: any, id: string) → string
Where the call that recorded node or scope `id` of `graph` was written: `path:line` in the graph's source, or nil when the graph was not built from a source file.
| arg | type | description |
|---|---|---|
| graph | any | A graph built in the call form. |
| id | string | A node or scope id of that graph. |
examples
local at = proc.builder.siteOf(graph, "merge_1") -- "/zero/source/city.procGraph/init.luau:12"
recordNode(graph: any, label: string, op: any, construct: string?, inputs: any, params: any) → string
A node of the call form: `op` is a node envelope or an op id.
| arg | type | description |
|---|---|---|
| graph | any | |
| label | string | |
| op | any | |
| construct | string? | |
| inputs | any | |
| params | any |
outputSocket(graph: any, id: string, output: string?) → any
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string | |
| output | string? |
wired(value: any, where: string, graph: any) → void
Wire a value: its ref, or `nil, value` for a plain constant.
| arg | type | description |
|---|---|---|
| value | any | |
| where | string | |
| graph | any |
refValue(value: any, where: string, graph: any) → any
A value as the ref a scope records: a socket's ref, a constant, a list or a record of those.
| arg | type | description |
|---|---|---|
| value | any | |
| where | string | |
| graph | any |
construct(graph: any, kind: string, named: { [string]: any }, params: { [string]: any }?) → any
One construct: a node the evaluator itself knows, wired from `named`.
| arg | type | description |
|---|---|---|
| graph | any | |
| kind | string | |
| named | { [string]: any } | |
| params | { [string]: any }? |
classKey(key: any) → boolean
Members, class views and writes
| arg | type | description |
|---|---|---|
| key | any |
rebind(b: Binding, ref: any) → void
| arg | type | description |
|---|---|---|
| b | Binding | |
| ref | any |
checkWritable(b: Binding, what: string) → void
| arg | type | description |
|---|---|---|
| b | Binding | |
| what | string |
memberSocket(b: Binding, key: any) → any
| arg | type | description |
|---|---|---|
| b | Binding | |
| key | any |
realize(b: Binding) → any
A class view read as a value: the member of its parent the key names.
| arg | type | description |
|---|---|---|
| b | Binding |
columnRead(view: Binding, name: any) → any
| arg | type | description |
|---|---|---|
| view | Binding | |
| name | any |
namesView(b: Binding) → any
`geometry.names[class]`: the attribute names a class holds, a list the plan answers.
| arg | type | description |
|---|---|---|
| b | Binding |
__index(_t: any, class: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| class | any |
__newindex( ) → void
stepMethod(b: Binding, key: string) → any
`step.sample(x)` and `step.between(index)`: the methods of the record a step body is handed.
| arg | type | description |
|---|---|---|
| b | Binding | |
| key | string |
columnWrite(view: Binding, name: any, value: any) → void
| arg | type | description |
|---|---|---|
| view | Binding | |
| name | any | |
| value | any |
__index(s: any, key: any) → void
| arg | type | description |
|---|---|---|
| s | any | |
| key | any |
__newindex(s: any, key: any, value: any) → void
| arg | type | description |
|---|---|---|
| s | any | |
| key | any | |
| value | any |
describeSocket(s: any) → string
| arg | type | description |
|---|---|---|
| s | any |
refuseComparison(op: string, form: string) → void
| arg | type | description |
|---|---|---|
| op | string | |
| form | string |
__len(_s: any) → void
| arg | type | description |
|---|---|---|
| _s | any |
__call(_s: any) → void
| arg | type | description |
|---|---|---|
| _s | any |
arithmetic(node: string) → void
| arg | type | description |
|---|---|---|
| node | string |
__unm(a: any) → void
| arg | type | description |
|---|---|---|
| a | any |
__iter(s: any) → void
`for _, item in list do ... end` over a socket: one pass of the body, which stands for every item and is written out per item by the evaluator.
| arg | type | description |
|---|---|---|
| s | any |
entryOf(ref: any) → Entry
| arg | type | description |
|---|---|---|
| ref | any |
bare(path: string) → string
A path as one spelling: the engine answers a world's content under `/zero/source` and `/source`.
| arg | type | description |
|---|---|---|
| path | string |
addTo(map: { [string]: { any } }, key: string, item: any) → void
| arg | type | description |
|---|---|---|
| map | { [string]: { any } } | |
| key | string | |
| item | any |
index( ) → Index
The listing of every node and graph, read again when the asset index moves. A node answers to its full name (rank 1) and to every dotted tail of it, its own name among them (rank 2); a graph is called by its path, its identity or `~`.
recordedCalls(source: string?) → void
The node each name a source calls was recorded as, by that name: the reference table of the asset holding the source names the guid every `g.<name>(...)` reached when it was written, and that record is what the name means wherever the source travels. Read once per source for the listing `index` last took.
| arg | type | description |
|---|---|---|
| source | string? |
rootOf(source: string?) → string
| arg | type | description |
|---|---|---|
| source | string? |
editDistance(a: string, b: string) → number
| arg | type | description |
|---|---|---|
| a | string | |
| b | string |
nearest(entries: { Entry }, name: string) → void
| arg | type | description |
|---|---|---|
| entries | { Entry } | |
| name | string |
readEntry(e: Entry) → string
| arg | type | description |
|---|---|---|
| e | Entry |
isCallForm(e: Entry) → boolean
| arg | type | description |
|---|---|---|
| e | Entry |
describeCandidates(list: { Entry }) → string
| arg | type | description |
|---|---|---|
| list | { Entry } |
statedKind(name: string) → string
The kind a path or `~` name states with its suffix (`.procNode` or `.procGraph`), or nil for one stating none: a name that states its kind names an asset of that kind alone.
| arg | type | description |
|---|---|---|
| name | string |
resolveEntry(graph: any, name: string) → Entry
The node a name resolves to, or an error naming the candidates.
| arg | type | description |
|---|---|---|
| graph | any | |
| name | string |
collect(match: (Entry) → void
| arg | type | description |
|---|---|---|
| match | (Entry |
collectFrom(list: { Entry }?) → void
| arg | type | description |
|---|---|---|
| list | { Entry }? |
callsByName(path: string) → boolean
Whether the `.procNode` at `path` is written in the call form (`proc.define(function(g) ... end)`), the form a graph calls by name as `g.<family>.<name>`. A node in another form is reached as the op it registers, `g.op.<name>`.
| arg | type | description |
|---|---|---|
| path | string | The node's folder path. |
examples
if proc.builder.callsByName(row.path) then print("g." .. row.name) endresolveNode(name: string) →
The node a name answers to, the way `g.<name>(...)` resolves it: its full name, its path and its guid.
| arg | type | description |
|---|---|---|
| name | string | A node's name (`points.disc`, or a short name one node alone answers to), a path, an identity or a guid. |
examples
local node = proc.builder.resolveNode("points.disc")loadNodeGraph(e: Entry) → void
| arg | type | description |
|---|---|---|
| e | Entry |
orderedKeys(map: any) → void
| arg | type | description |
|---|---|---|
| map | any |
infoOfEntry(e: Entry) → Info
| arg | type | description |
|---|---|---|
| e | Entry |
infoOfOp(id: string) → Info
| arg | type | description |
|---|---|---|
| id | string |
plainNamed(arg: any, info: Info) → boolean
Calls
| arg | type | description |
|---|---|---|
| arg | any | |
| info | Info |
acceptedNames(info: Info) → string
| arg | type | description |
|---|---|---|
| info | Info |
takesRecord(spec: any) → boolean
Whether an input declared as `spec` takes a record of values whole.
| arg | type | description |
|---|---|---|
| spec | any |
bind(graph: any, info: Info, display: string, packed: any) → void
| arg | type | description |
|---|---|---|
| graph | any | |
| info | Info | |
| display | string | |
| packed | any |
outputNames(info: Info) → void
| arg | type | description |
|---|---|---|
| info | Info |
callEntry(graph: any, label: string, op: any, info: Info, display: string, packed: any) → void
| arg | type | description |
|---|---|---|
| graph | any | |
| label | string | |
| op | any | |
| info | Info | |
| display | string | |
| packed | any |
__index(_t: any, key: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| key | any |
callByName(graph: any, name: string, packed: any) → void
| arg | type | description |
|---|---|---|
| graph | any | |
| name | string | |
| packed | any |
callOp(graph: any, id: string, packed: any) → void
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string | |
| packed | any |
outputsOf(op: any) →
The names of the outputs a node of the call form returns, in the order `g.<name>(...)` asset, or the id of an op. A construct has one output.
| arg | type | description |
|---|---|---|
| op | any | The `op` field of a recorded node. |
call(graph: any, name: string, ...: any) → void
Call the node `name` of `graph` with `args` (a table naming inputs, or positional values). Returns the node's outputs in declared order.
| arg | type | description |
|---|---|---|
| graph | any | |
| name | string | |
| ... | any |
callOp(graph: any, id: string, ...: any) → void
Call the op `id` of `graph`.
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string | |
| ... | any |
namespace(graph: any, segments: { string }, isOp: boolean) → any
A namespace: `g.points` stands for the name `points`, `g.points.disc` for `points.disc`; calling it adds the node.
| arg | type | description |
|---|---|---|
| graph | any | |
| segments | { string } | |
| isOp | boolean |
__index(_t: any, seg: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| seg | any |
__call(_t: any, ...: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| ... | any |
__tostring( ) → void
compareOp(a: any, op: any, b: any, graph: any) → any
| arg | type | description |
|---|---|---|
| a | any | |
| op | any | |
| b | any | |
| graph | any |
whereOp(cond: any, a: any, b: any, graph: any) → any
| arg | type | description |
|---|---|---|
| cond | any | |
| a | any | |
| b | any | |
| graph | any |
pickOp(choice: any, alternatives: any, graph: any) → any
`g.pick(choice, alternatives)`: `alternatives` is keyed by option name, keyed by `false` and `true`, or a list where a false choice takes the first entry and a true one the second, and a number takes that position. A choice known while the graph is built picks there; a socket records the pick, and only the chosen alternative cooks.
| arg | type | description |
|---|---|---|
| choice | any | |
| alternatives | any | |
| graph | any |
openScope(graph: any, kind: string, fields: any) → string
| arg | type | description |
|---|---|---|
| graph | any | |
| kind | string | |
| fields | any |
closeScope(graph: any, id: string) → void
| arg | type | description |
|---|---|---|
| graph | any | |
| id | string |
foldOp(graph: any, count: any, init: any, fn: any, opts: any?) → any
`g:fold(n, init, fn)`: `fn(value, i)` is built once and written out n times in a chain, each reading the one before.
| arg | type | description |
|---|---|---|
| graph | any | |
| count | any | |
| init | any | |
| fn | any | |
| opts | any? |
stepOp(graph: any, dt: any, substeps: any, fn: any) → any
`g:step(dt, substeps, fn)`: `fn(state, step)` advances the declared state by one fixed step and returns the next.
| arg | type | description |
|---|---|---|
| graph | any | |
| dt | any | |
| substeps | any | |
| fn | any |
stateOp(graph: any, name: any, columns: any) → any
`g:state(name, columns)`: device columns the runtime keeps across presents.
| arg | type | description |
|---|---|---|
| graph | any | |
| name | any | |
| columns | any |
checkOp(graph: any, cond: any, message: any) → any
`g:check(cond, message)`: a condition known while the graph is built refuses the build; one that reads a socket is recorded for the plan or the cook to answer.
| arg | type | description |
|---|---|---|
| graph | any | |
| cond | any | |
| message | any |
readsSocket(v: any, seen: { [any]: boolean }) → boolean
| arg | type | description |
|---|---|---|
| v | any | |
| seen | { [any]: boolean } |
hasOp(graph: any, geometry: any, class: any, name: any) → any
| arg | type | description |
|---|---|---|
| graph | any | |
| geometry | any | |
| class | any | |
| name | any |
copyOp(graph: any, value: any) → any
| arg | type | description |
|---|---|---|
| graph | any | |
| value | any |
colonOrDot(ref: { any }, fn: (...any) → void
A method that takes the graph first when written `g:name(...)` and nothing first when written `g.name(...)`, the graph read through `ref`.
| arg | type | description |
|---|---|---|
| ref | { any } | |
| fn | (...any |
methodsOf(graph: any) → void
| arg | type | description |
|---|---|---|
| graph | any |
__index(_t: any, kind: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| kind | any |
sceneValue(graph: any, what: string) → any
The socket answering where the graph stands in the scene it is cooked in: `entity` the entity it stands on, `placement` its matrix (16 numbers, column after column), `inverse` the matrix that takes world values into the graph's space, `rotation` the turn the placement makes as `{ x, y, z, w }`. Read as `g.clock.placement`, `g.clock.inverse`, `g.clock.rotation` and `g.clock.entity`.
| arg | type | description |
|---|---|---|
| graph | any | The graph being built. |
| what | string | entity, placement, inverse or rotation. |
transformView(graph: any) → any
`g.transform`: carries values of the world into the graph's own space, the space whose origin is the entity the graph stands on. `point` applies the inverse of the placement, `direction` only its turn and scale, `rotation` composes the inverse of the placement's turn with a quaternion.
| arg | type | description |
|---|---|---|
| graph | any |
matrix( ) → any
vec3(x: any, y: any, z: any) → any
| arg | type | description |
|---|---|---|
| x | any | |
| y | any | |
| z | any |
__index(_t: any, key: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| key | any |
elementView(graph: any) → any
`g.element`: the element a Field evaluates over. `.id` is its index, `.P` its position leaf, and `.<class>.<column>` a column of the domain it stands in. Each read is a socket of its own.
| arg | type | description |
|---|---|---|
| graph | any |
leaf(field: string, class: string?) → any
| arg | type | description |
|---|---|---|
| field | string | |
| class | string? |
__index(_t: any, key: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| key | any |
__index(_c: any, name: any) → void
| arg | type | description |
|---|---|---|
| _c | any | |
| name | any |
__tostring( ) → void
index(graph: any, key: string) → any
What `graph.<key>` answers when the graph has no such field or method: the builder's constructs, or a namespace for a node or op name.
| arg | type | description |
|---|---|---|
| graph | any | |
| key | string |
anySocket(...: any) → boolean
`math.*` and `vector.*` over sockets
| arg | type | description |
|---|---|---|
| ... | any |
plainVector(...: any) → any
`vector.create` over two or four numbers: the vector record `math.vec2` or `math.vec4` folds those numbers to, so a call has the width of its component count whether its arguments are numbers or sockets. Three numbers, and any other arguments, answer nil and take Luau's own vector.
| arg | type | description |
|---|---|---|
| ... | any |
aware(real: any, prefix: string, rename: { [string]: string }?) → any
| arg | type | description |
|---|---|---|
| real | any | |
| prefix | string | |
| rename | { [string]: string }? |
__index(_t: any, key: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| key | any |
held(...: any) → void
| arg | type | description |
|---|---|---|
| ... | any |
unit(seed: any, ...: any) → void
| arg | type | description |
|---|---|---|
| seed | any | |
| ... | any |
__index(_t: any, seg: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| seg | any |
__call(_t: any, id: any) → void
| arg | type | description |
|---|---|---|
| _t | any | |
| id | any |
isVectorTable(v: any) → string
| arg | type | description |
|---|---|---|
| v | any |
isColorTable(v: any) → boolean
| arg | type | description |
|---|---|---|
| v | any |
shapeOf(value: any, where: string) → any
What a default value is, as `{ type, fields?, element? }`.
| arg | type | description |
|---|---|---|
| value | any | |
| where | string |
checkOptions(name: string, options: any, typ: string) → void
| arg | type | description |
|---|---|---|
| name | string | |
| options | any | |
| typ | string |
isOlderForm(second: any, opts: any) → boolean
Whether `second` is the type name of the older `g:input(name, "Float", { default })` form.
| arg | type | description |
|---|---|---|
| second | any | |
| opts | any |
describeInput(name: string, default: any, opts: any?) → any
The declaration `g:input(name, default, opts)` records: the type comes from the default (or `opts.type`), and a list or record default states its fields.
| arg | type | description |
|---|---|---|
| name | string | |
| default | any | |
| opts | any? |
isPlain(decl: any) → boolean
Whether an input declaration states a build-time value: it is declared `plain = true` (a count, a vector, a record or a list that chooses the graph's structure), it has `options`, or it is a Bool or a String. Such an input is the plain value itself while the graph is built, so `if` over it is allowed.
| arg | type | description |
|---|---|---|
| decl | any | A declaration from `describeInput`. |
wiredInput(graph: any, name: string) → any
The value an optional input with no default stands for in the build of `graph`: nil when the build was made for a call that leaves it unwired (`values[name] == false`), else the socket of the input. The graph records which in `graph.wiring[name]`, so `if input == nil` in a node source is decided by what the call wired.
| arg | type | description |
|---|---|---|
| graph | any | The graph being built. |
| name | string | The input's name. |
plainValue(graph: any, name: string, decl: any) → any
The value a plain input stands for in the build of `graph`: the one the build was given, or the declaration's default. The graph records it in `graph.plain[name]`.
| arg | type | description |
|---|---|---|
| graph | any | The graph being built. |
| name | string | The input's name. |
| decl | any | The input's declaration. |
frozenCopy(value: any) → any
A plain value as a build reads it: a table is copied whole and frozen, every table inside it too, so the build can neither change the declaration's default nor the values a caller handed in; any other value is itself.
| arg | type | description |
|---|---|---|
| value | any | A plain value. |
examples
local spec = builder.frozenCopy({ bays = { 2, 3 } })notBuildTime(value: any) → string
What a value handed to a plain input is when it is not a value known while the graph is built: an animated value, a per-element Field, a value held on the device, or a socket. Nil for a value a build can read.
| arg | type | description |
|---|---|---|
| value | any |
shapeMismatch(shape: any, value: any, path: string) → string
Whether `value` has the shape `shape` states.
| arg | type | description |
|---|---|---|
| shape | any | |
| value | any | |
| path | string |
refusedValue(decl: any, value: any, name: string) → string
The sentence saying why `value` is not one the input `decl` holds, or nil when it holds it: a value outside the input's `options`, past its `min` or `max`, or not of its type.
| arg | type | description |
|---|---|---|
| decl | any | The input's declaration, `graph.inputs[name]`. |
| value | any | The value to check. |
| name | string | The input's name, for the message. |
noteNodeCall(graph: any) → void
Note that `graph` placed a node with `g:node`: a graph source is warned about once.
| arg | type | description |
|---|---|---|
| graph | any |
resetWarnings( ) → void
Forget which graph sources were warned about (for a test).
tokenize(src: string) → void
| arg | type | description |
|---|---|---|
| src | string |
push(t: string, v: string) → void
| arg | type | description |
|---|---|---|
| t | string | |
| v | string |
unquote(text: string) → string
| arg | type | description |
|---|---|---|
| text | string |
plainInput(toks: { Token }, open: number) → boolean
Whether the `g:input(` call whose parenthesis is `open` declares a build-time value: a Bool or String (by its default or its stated type), an input with `options`, or one declared `plain = true`.
| arg | type | description |
|---|---|---|
| toks | { Token } | |
| open | number |
isOpenTok(t: Token) → boolean
| arg | type | description |
|---|---|---|
| t | Token |
isCloseTok(t: Token) → boolean
| arg | type | description |
|---|---|---|
| t | Token |
primaries(toks: { Token }, from: number, to: number) → void
The depth-0 primaries of tokens[from..to]: the leftmost name of each chain.
| arg | type | description |
|---|---|---|
| toks | { Token } | |
| from | number | |
| to | number |
spanLeft(toks: { Token }, at: number) → void
The span of the operand of an operator at `at`, to the left or right: it runs over arithmetic and balanced groups and stops at a boundary.
| arg | type | description |
|---|---|---|
| toks | { Token } | |
| at | number |
spanRight(toks: { Token }, at: number) → void
| arg | type | description |
|---|---|---|
| toks | { Token } | |
| at | number |
exprEnd(toks: { Token }, from: number) → number
The end of the expression that starts at `from`: it continues over operators, member and call chains, and balanced groups.
| arg | type | description |
|---|---|---|
| toks | { Token } | |
| from | number |
expressionIfs(toks: { any }) → void
The `if` tokens of a token list that begin an `if` expression, and the `then`, `elseif` and `else` tokens that belong to one: an `if` a value follows (`VALUE_FOLLOWS`, an operator, or a `then` / `else` of an `if` expression).
| arg | type | description |
|---|---|---|
| toks | { any } |
blockEnd(toks: { any }, from: number, exprIfs: { [number]: boolean }?) → number
The index of the `end` that closes the block a `do`, `function` or `if` at `from` opens. An `if` expression (`exprIfs`, from `expressionIfs`) opens none.
| arg | type | description |
|---|---|---|
| toks | { any } | |
| from | number | |
| exprIfs | { [number]: boolean }? |
check(source: string) →
Check a graph source for Luau comparisons and logic over sockets, which have no value while a graph is built. Reads the source, follows which names hold sockets (an input, a call of `g.<name>`, a fold or step parameter, a loop item, anything computed from those) block by block, as Luau scopes them: a local, a loop variable or a function parameter is its block's own, and the outer name stands again after the block. It reports every `< <= > >= == ~=` with a socket on either side, and every `and` / `or` whose left operand, `not` whose operand and `if` / `while` condition that reads one, naming the `g.*` form to write. A comparison with `nil` is a build-time test and is allowed. A parameter of a function that is not a fold, step or stop body is not known to be a socket (a comparison over one is refused when the graph is built).
| arg | type | description |
|---|---|---|
| source | string | The text of a graph's `init.luau`. |
examples
local problems = proc.builder.check(vfs.read(path .. "/init.luau"))
report(line: number, code: string, message: string) → void
| arg | type | description |
|---|---|---|
| line | number | |
| code | string | |
| message | string |
hasSocket(from: number, to: number) → boolean
| arg | type | description |
|---|---|---|
| from | number | |
| to | number |
producesSocket(from: number, to: number) → boolean
Does tokens[from..to] produce a socket?
| arg | type | description |
|---|---|---|
| from | number | |
| to | number |
openBlock(closes: number) → void
| arg | type | description |
|---|---|---|
| closes | number |
restoreOuter(block: Block) → void
| arg | type | description |
|---|---|---|
| block | Block |
declare(name: string, socket: boolean) → void
Declare `name` in the innermost block, standing for a socket when `socket` holds.
| arg | type | description |
|---|---|---|
| name | string | |
| socket | boolean |
prepareSource(source: string) → string
The source as the graph loader should compile it: with `math` and `vector` bound to the socket-aware ones, on the source's first line.
| arg | type | description |
|---|---|---|
| source | string | The text of a node or graph `init.luau`. |
chunkPath(fn: any) → string
The path of the node or graph entry a builder function was compiled from, or nil for any other chunk: only a `.procNode` or `.procGraph` entry is read again and checked.
| arg | type | description |
|---|---|---|
| fn | any |
usesMath(src: string) → boolean
| arg | type | description |
|---|---|---|
| src | string |
checkSourceOf(fn: any) → void
Hold the source a builder function came from to the static check, once per source text. An error lists every refused line.
| arg | type | description |
|---|---|---|
| fn | any |
reloadAware(fn: any) → any
The graph the builder function's own source builds when loaded with `math` and `vector` socket-aware, or nil when that is not needed or not possible. `define` calls it before building so a formula written with the plain `math` reads unchanged.
| arg | type | description |
|---|---|---|
| fn | any |
isReloading(fn: any) → boolean
Whether the source of `fn` is being run again by `reloadAware`.
| arg | type | description |
|---|---|---|
| fn | any |
sourceOf(fn: any) → string
The path of the chunk a function came from.
| arg | type | description |
|---|---|---|
| fn | any |
samePlain(a: any, b: any) → boolean
Whether two plain values are the same value: tables by their content, anything else by equality.
| arg | type | description |
|---|---|---|
| a | any | |
| b | any |
plainKey(value: any) → string
A plain value as part of a build's key: a table by its content.
| arg | type | description |
|---|---|---|
| value | any |
keepBuild(path: string, key: string) → void
Mark the build `key` of the source at `path` as used now, and let go of the builds of that source used longest ago past `KEPT_BUILDS_PER_SOURCE`.
| arg | type | description |
|---|---|---|
| path | string | |
| key | string |
withInputs(values: { [string]: any }, fn: () →
Run `fn`, which builds a graph with `proc.define`, giving the graph the plain input values `values` (inputs declared `plain = true`, inputs with `options`, and Bool and String inputs). An input the table does not name keeps its default.
| arg | type | description |
|---|---|---|
| values | { [string]: any } | A table of input name to value. |
| fn | ( | The function that builds the graph, normally the loaded chunk of a node or graph source. |
rebuild(graph: any, values: { [string]: any }) →
The graph `graph` source builds when its plain inputs hold `values`, read from `graph.source` and run again.
| arg | type | description |
|---|---|---|
| graph | any | A graph built in the call form. |
| values | { [string]: any } | A table of input name to value. |
forInputs(graph: any, inputs: { [string]: any }?) →
The graph to cook for `inputs`: `graph` itself while its plain inputs hold what the build used, else the graph built again with the values `inputs` states (the declaration's default for an input it leaves out). Values are compared by content, a record or a list included. The builds are cached by the source and the values, and `KEPT_BUILDS_PER_SOURCE` of each source's builds, the ones used last, are kept.
| arg | type | description |
|---|---|---|
| graph | any | A graph. |
| inputs | { [string]: any }? | A table of input name to value, or nil. |
keptBuilds(path: string) → number
How many builds `forInputs` keeps of the source at `path`.
| arg | type | description |
|---|---|---|
| path | string | The source's path (`graph.source`). |
freeze(t: any) → void
Freeze `t` and the plain tables under it. A table with a metatable or a `__proc_type` (a Geometry, a Column, a Field) is a value compared by identity, and is left as it is.
| arg | type | description |
|---|---|---|
| t | any |
pass(graph: any) → void
The pass after the run of a build of a graph source that has a base: every node the run made is compared with the base's node of the same id (`replan`'s `compareNode`, and the node's op field by field). An equal node is replaced in `graph.nodes` by the base's own table, which is frozen, and keeps this build's place in the order the nodes were made in when that place moved (`_moved`). A node that differs, or that the base does not hold, is frozen and listed. The scopes are compared and the ones that differ are listed; they stay this build's own tables. `_diff` states the result for the planner: the graph it was made against, held weakly, the ids listed, the ids of the base that the build did not make, the counts of the nodes and scopes, and the edit counts of both graphs when the pass ran.
| arg | type | description |
|---|---|---|
| graph | any |
setBuildAgainstBase(on: boolean) → boolean
Switch the pass that follows a build on or off for the builds after: with it on, a build of a graph source that has a base (`setBase`) files the base's own table for every node that is equal to the base's and lists the ones that are not. Off, a build is the graph its run made.
| arg | type | description |
|---|---|---|
| on | boolean | Whether a build is made against its base. |
examples
local was = proc.builder.setBuildAgainstBase(false)
againstCounts( ) →
What the pass after a build has done since the module loaded: the builds it ran after (`passes`), the nodes it filed from the base (`reused`) and the nodes it listed (`changed`), and the nodes `proc.edit` copied to write into (`copies`), and the time the passes took in ms (`ms`).
examples
local counts = proc.builder.againstCounts()
noteCopy( ) → void
Count one node that `proc.edit` copied because the graph shared its table with the graph it was built against.
examples
proc.builder.noteCopy()
setBase(graph: any) → void
Make `graph` the base of the builds of its source: the graph a Generator plays. Held weakly. A graph that is not of the call form, or has no source, is not a base.
| arg | type | description |
|---|---|---|
| graph | any | A graph built from a source file. |
examples
proc.builder.setBase(ticket.graph)
baseOf(entry: string) → any
The graph the builds of the entry source `entry` are made against, or nil.
| arg | type | description |
|---|---|---|
| entry | string | The entry source's path. |
examples
local base = proc.builder.baseOf(entry)
seqOf(graph: any, id: string) → number
The place node `id` of `graph` holds in the order the nodes were made in: the node's own `seq`, or the one this build gave it when the node is the base's table, which keeps the place the base's build gave it.
| arg | type | description |
|---|---|---|
| graph | any | A graph. |
| id | string | A node id. |
examples
local at = proc.builder.seqOf(graph, "merge_1")
documentNodes(graph: any) → any
The nodes of `graph` as a document states them: the graph's own table, or when some of its nodes are the base's tables with another place in the order, a copy in which those nodes state the place this build gave them.
| arg | type | description |
|---|---|---|
| graph | any | A graph. |
examples
local nodes = proc.builder.documentNodes(graph)
documentNode(graph: any, id: string, node: any) → any
Node `id` of `graph` as a document states it: the node itself, or when it is the base's table with another place in the order, a copy that states the place this build gave it.
| arg | type | description |
|---|---|---|
| graph | any | A graph, or a document. |
| id | string | The node's id. |
| node | any | The node the graph holds under `id`. |
examples
local node = proc.builder.documentNode(graph, id, graph.nodes[id])
run(graph: any, fn: (any) → void
Run `fn(g)` with `g` the graph being built, then close any `for` body left open, and record what `fn` returns as the graph's outputs: a table of name to value, in the order the values were made.
| arg | type | description |
|---|---|---|
| graph | any | |
| fn | (any |
forget(folder: string) → void
Forget what the builder holds of the node or graph in the folder `folder`: its source text and the graph its source built, so the next build that reaches it runs its source again. Called when something its build read changed while its own source did not.
| arg | type | description |
|---|---|---|
| folder | string | The `.procNode` or `.procGraph` folder. |
examples
proc.builder.forget("/zero/source/fx/spark.procNode")reset( ) → void
Forget the cached node index and node graphs (for a test that writes nodes).
isolated(fn: () → void
Run `fn` with a graph-building state of its own on the calling thread: no graph being built, no node or source being loaded and no plain input values waiting for a build. Other threads keep theirs, whatever `fn` waits on. The caller's state is back when `fn` returns or raises, and an error `fn` raises is raised again. What the state caches (node graphs, the node index, checked sources) is shared.
| arg | type | description |
|---|---|---|
| fn | ( | The function to run. |
examples
builder.isolated(function() registry.listAssets() end)
callByName(graph: any, name: string, ...: any) → void
| arg | type | description |
|---|---|---|
| graph | any | |
| name | string | |
| ... | any |
clockSocket(graph: any, field: string) → any
The socket for one field of a graph's clock.
| arg | type | description |
|---|---|---|
| graph | any | |
| field | string |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
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.