Skip to content

Search

Dokumentace

scene

The node tree: its root, lookup by path and instancing, plus the component vocabulary an editor's palette lists.

Na této stránce

The node tree: its root, lookup by path and instancing, plus the component vocabulary an editor's palette lists.

25 functions, 0 constants. Scripts reach it as scene::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
attach_scripts(Node) — Run every script the nodes under a node name, children first: what starts a scene built with scripts: false.
bindable_events(Node?) -> [str] — Every event a [[nodes.bindings.rows]] row may answer, in the order an editor offers them: the core hooks, and on a node the emitted: events it, its components and its script announce.
binding_actions() -> [str] — Every action a binding row may do, in the order an editor offers them.
component_expects(string) -> [str]? — The components a component type needs something from, for ordering or grouping its sections; nil for a name nothing registered.
component_properties(string, any) -> any — What a component's apply would receive for params: the schema's defaults with a partial table merged over them. This is how a tool compares two spellings of the same component.
component_schema(string) -> any — A component type's property schema as a table, its properties in the order it writes them; nil for a name nothing registered.
component_tags(string) -> [str]? — The facets a component type is filed under, for filtering a palette; nil for a name nothing registered.
component_types() -> [str] — The names of every registered component type, not the components on any node.
current(Node?) -> Node — The root of the scene the last switch, or the run's start, built under a node, the tree's root when nil; no node while none stands there.
instantiate(string, Node?, scene::InstantiateOptions?) — Build a scene document (TOML text, not a path) under a parent. scripts: false names each node's script without running it; root is the project the text names its files from, when it is not this one, and every path is made absolute against it; under a node of the content the engine plays, that project is the default.
keep_changes(Node?) — Keep every change under a node as it happens, each with what it replaced, until take_changes hands them over; nil stops, and what was kept goes. An editor's undo, which the changed event serves a frame late and merged.
node_by_id(string, Node?) -> Node — The node carrying a stable id, which survives the rename and the reparent a path does not; nil when nothing carries it. under bounds the search to one subtree, for a tool holding more than one tree.
preload(string) — Ready a scene before a switch to it: its file and every prefab under it read and parsed now, and the pictures they name decoding on a worker thread. No node is built and nothing in the world changes, so a replay that never preloaded builds the same world. An error when a file does not read or parse, said now rather than at the switch.
repeat(Node, [scene::RepeatItem]) -> [Node] — One instance of each item's scene file under host, in the items' order after the host's other children, and the instance's root for each. An instance is kept from call to call: the same key keeps its node, a new key takes a spare of the same scene, and an instance no item asks for is hidden, not freed, so a list asked for every pass builds only when it grows. Each root is named for its item's key, so a binding row handing over the node says which item it is; a spare is named spare0, spare1 and on. An instance's stable ids are the file's under <host id>/<n>/, as a prefab instance's are. A scene file with more than one root is an error, as are two items sharing a key and a key that is empty or holds a /.
root() -> Node — The tree's root node.
set_variable(string, any) — Write a scene variable, coerced to the type it was declared with. Every node declaring on_variable_changed hears about it at the end of the tick; writing the value it already holds says nothing.
switch(string, scene::SwitchOptions?) — Go to another scene at the end of this tick, so a script asking inside update is not moving the tree it runs in. The scene the last switch built under under is freed, each of its scripts' on_free running, and path is built there new, every init running: a visit always starts fresh, and a switch to the file already there is a reset. under is the tree's root when nil, where the main scene stands; only that scene's own root goes, so a node a script made beside it under the same parent stays and keeps running. fade is seconds of crossover: the old scene's root fades out to the clear colour over the first half, the switch happens, and the new one fades in over the second. A scene preload warmed builds from its caches; one it did not is read on the frame.
tagged(string) -> [Node] — Every node filed under a tag, in tree order; what a scene's tags key and node.add_tag feed.
take_changes() -> [scene::Change] — The changes kept since the last take, oldest first, emptying the list: { node, kind, id } with kind one of component (component, properties, was: the table asked before), attached, removed (was), added (parent), freed (parent, place, was: the subtree as scene text), renamed (was), moved (parent, was: { parent, place }), script (was: { source, props }, nil for none) and keys (was: every one of the node's own keys, visible to tags). Parents are stable ids, so a change outlives the nodes it names.
to_toml(Node, scene::ToTomlOptions?) -> string — The scene under a node, that node its root, as a scene file's text: what instantiate builds again. Each component is what was asked of it, a prefab's nodes are their instance's overrides, and root writes every path under that project's root as it spells it.
unload(string) — Let go of what preload, or a pack warming its scenes, readied: the parsed text of the file and its prefabs, and the pictures they name. A scene standing stays where it is, and a picture something still draws is read again when it next asks.
variable(string) -> any — A scene variable's value, or nil for a name nothing declared. A scene declares them under [variables].
variables() -> [scene::Variable] — Every declared variable as { name, type, value }, in name order.
warnings(Node) -> [scene::Warning] — What is off about the node, as { component, property, message }: a component missing one it expects, a write its component refused, and what a component says of itself. property is nil for the whole component; advisory only.
with_component(string) -> [Node] — Every node carrying the named component, in tree order. What a script asks instead of walking the tree itself.

Opravdu?