Entity
The Entity namespace — 15 functions.
globals/Entity/allTypes
Entity.allTypes() -> { string }
List all registered reflectable component types in this engine instance.
Returns { string } — Array of component name strings.
local types = Entity.allTypes()
globals/Entity/distance
Entity.distance(entityIdA: string, entityIdB: string) -> number?
Compute the straight-line distance between two entities' Transform.position fields.
Parameters
entityIdAstring— First entity id.entityIdBstring— Second entity id.
Returns number? — The distance, or nil when either entity is missing a position.
local d = Entity.distance("player", "enemy")
globals/Entity/getComponents
Entity.getComponents(entityId: string) -> { string }?
List all reflected component types on an entity.
Parameters
entityIdstring— The entity id.
Returns { string }? — Array of component name strings, or nil when the entity has no reflected components.
local comps = Entity.getComponents("player")
globals/Entity/getField
Entity.getField(entityId: string, component: string, field: string) -> any
Get a specific component field value. An engine-struct component reads through reflection; a component declared in Luau reads through its component ref, so one call serves both.
Parameters
entityIdstring— The entity id.componentstring— The component name (e.g."Transform","Model").fieldstring— The field name (e.g."position","tintBlend").
Returns any — The field value, or nil when the entity/component/field is missing. A component name this engine does not declare raises.
local pos = Entity.getField("player", "Transform", "position")
globals/Entity/getName
Entity.getName(entityId: string) -> string?
Get the name of an entity from its Name component.
Parameters
entityIdstring— The entity id.
Returns string? — The name string, or nil when the entity has no Name component.
local name = Entity.getName("player")
globals/Entity/getPosition
Entity.getPosition(entityId: string) -> Vec3?
Get the position of an entity — shortcut for getField(id, "Transform", "position").
Parameters
entityIdstring— The entity id.
Returns Vec3? — The position { x, y, z }, or nil when the entity has no Transform.
local pos = Entity.getPosition("player")
globals/Entity/getRotation
Entity.getRotation(entityId: string) -> Quat?
Get the rotation of an entity — shortcut for getField(id, "Transform", "rotation").
Parameters
entityIdstring— The entity id.
Returns Quat? — The rotation quaternion { x, y, z, w }, or nil when the entity has no Transform.
local rot = Entity.getRotation("player")
globals/Entity/getScale
Entity.getScale(entityId: string) -> Vec3?
Get the scale of an entity — shortcut for getField(id, "Transform", "scale").
Parameters
entityIdstring— The entity id.
Returns Vec3? — The scale { x, y, z }, or nil when the entity has no Transform.
local scale = Entity.getScale("player")
globals/Entity/getSchema
Entity.getSchema(componentName: string) -> { ComponentFieldSchema }?
Get the full schema of a component type — field names + types.
Parameters
componentNamestring— The component name.
Returns { ComponentFieldSchema }? — Array of { name, type } schema entries, or nil when the component is not registered.
local schema = Entity.getSchema("Transform")
globals/Entity/isVisible
Entity.isVisible(entityId: string) -> boolean
Check if an entity is visible — reads the Visible component. Missing component is treated as visible.
Parameters
entityIdstring— The entity id.
Returns boolean — true when visible (or no Visible component is present), false when explicitly hidden.
local visible = Entity.isVisible("player")
globals/Entity/patch
Entity.patch(entityId: string, component: string, fields: { [string]: any }) -> boolean
Patch multiple fields on a single component at once. Serves an engine-struct component and a component declared in Luau alike.
Parameters
entityIdstring— The entity id.componentstring— The component name.fields{ [string]: any }—{ fieldName = value, ... }map of fields to write.
Returns boolean — true when every named field was written. A component name this engine does not declare raises.
Entity.patch("player", "Transform", { position = pos, scale = scl })
globals/Entity/setField
Entity.setField(entityId: string, component: string, field: string, value: any?) -> boolean
Set a specific component field value. An engine-struct component writes through reflection; a component declared in Luau writes through its component ref, so one call serves both.
Parameters
entityIdstring— The entity id.componentstring— The component name.fieldstring— The field name.valueany(optional) — The new value.
Returns boolean — true when the write succeeded, false otherwise. A component name this engine does not declare raises.
Entity.setField("player", "Transform", "position", { x = 0, y = 1, z = 0 })
globals/Entity/setPosition
Entity.setPosition(entityId: string, pos: Vec3)
Set the position of an entity — shortcut for setField(id, "Transform", "position", pos).
Parameters
entityIdstring— The entity id.posVec3— The new position{ x, y, z }.
Entity.setPosition("player", { x = 0, y = 1, z = 0 })
globals/Entity/setScale
Entity.setScale(entityId: string, scale: Vec3)
Set the scale of an entity — shortcut for setField(id, "Transform", "scale", scale).
Parameters
entityIdstring— The entity id.scaleVec3— The new scale{ x, y, z }.
Entity.setScale("player", { x = 1, y = 1, z = 1 })
globals/Entity/snapshot
Entity.snapshot(entityId: string) -> any
Snapshot all reflected components on an entity into a { ComponentName = { field = value, ... }, ... } map.
Parameters
entityIdstring— The entity id.
Returns any — The snapshot table, or nil when the entity does not exist.
local snap = Entity.snapshot("player")