Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit44fd9e59bd

README.md

entityOps.component

Inspect a component type so you set fields that exist instead of guessing. Reports the component's public fields (name + type + current value), its callable methods, its lifecycle hooks, and its asset-ref fields.

entityOps.component("Camera")                 -- fields, methods, hooks + default values
entityOps.component("Model", { on = "my_prop" })  -- actual values on that entity
entityOps.component("@builtin::components.Light")

Resolves the component by name / identity / VFS path. Pass on (an entity name or id that carries the component) and every field's value is that entity's actual value, read off its live component proxy; omit on and each value is the declared default, as written in the component's source.

A live value keeps its shape: a number reads back as a number, a vector or struct as its plain table. A field that resolves on read reports the identity of what it points at — an asset (resource / assetRef) as a { __ref, identity, name, type } envelope whose identity you hand straight back to addComponents, an entityRef as the entity id. A field whose live value could not be read carries an error instead of a value, so a value that failed to read is never mistaken for the default.

-- on a wall carrying a mesh and a custom material
entityOps.component("Model", { on = "wall_north" })
-- fields: model    = { __ref = "336f4feb-…", identity = "@builtin::meshes.cube",  name = "cube",  type = "mesh" }
--         material = { __ref = "99d699e9-…", identity = "@user::materials.brick", name = "brick", type = "material" }

Returns { identity, description, builtin, executionOrder, hooks, fields, methods, assetFields, source }. Reach for it before entityOps.addComponents / entityOps.spawn to learn the exact field names and value shapes — the fix for setting fields a component doesn't have.

To inspect the components + values on an entity (rather than a component type's schema), use debug.inspect.