API Reference › Reflect
namespace

Reflect

Runtime reflection over the world schema — inspect properties, fields, and entity state by name and by index. It powers the conveniences game devs consume without writing reflection code: automatic save/load, data-driven tools, and debug/inspector overlays. Enumerate with Reflect.prop_count/Reflect.prop_name and Reflect.field_count/Reflect.field_name/Reflect.field_type; resolve ids with Reflect.prop/Reflect.field; read and write an entity's fields with Reflect.get/Reflect.set/Reflect.has; and identify its model with Reflect.kind/Reflect.model. The metadata tables are generated at compile time (the same reflection ABI a foreign mod binds), so introspection is a table walk, not heavy runtime machinery. This is an advanced/tooling surface — most developers get its benefits through built-in features. Related: World, Query.

Reflect.prop(name) -> intThe property id for a property name, or -1 if unknown.Reflect.field(prop, name) -> intThe field id of a named field within a property, or -1.Reflect.prop_count() -> intHow many properties the world schema defines.Reflect.prop_name(index) -> stringThe name of the property at an index (or "").Reflect.field_count(prop) -> intHow many fields a property has.Reflect.field_name(prop, index) -> stringThe name of the field at an index within a property.Reflect.field_type(prop, index) -> stringThe type name of the field at an index within a property.Reflect.get(entity, prop, field) -> intRead one field of an entity by (prop, field) id.Reflect.set(entity, prop, field, value)Write one field of an entity by (prop, field) id.Reflect.has(entity, prop) -> boolDoes an entity carry a property?Reflect.kind(entity) -> intThe model id of an entity.Reflect.model(name) -> intThe model id for a model name, or -1 if unknown.Reflect.serialize(entity) -> valueWalk an entity's components into a value tree.Reflect.apply(entity, value) -> intWrite a value tree's fields back into an entity.
← All symbols