Object
Client
Server
The object visible in the hierarchy. Every object has a transform and can have additional components attached to it.
Metamethods
boolean __eq(Object a, Object b)
Methods
Vec3 LocalToWorld(Vec3 point)
Transforms a local position to world space, allowing you to convert coordinates relative to an object into global coordinates.
Vec3 WorldToLocal(Vec3 point)
Converts a world position to local space, making it useful for determining an object's position relative to another object.
Vec3 LocalToWorldVec(Vec3 vec)
Vec3 WorldToLocalVec(Vec3 vec)
nil LookAt(Vec3 pos, Vec3? up)
Rotates the object to face the given world point (optional up vector).
Object? GetChild(string name)
Get child object by name
Script AddScript(string fileName, boolean? sync)
Mesh AddMesh()
VoxelData? AddVoxelData()
StaticVoxelData? AddStaticVoxelData(string fileName)
VoxelData AddVoxelRenderer()
Camera AddCamera()
Sky AddSkybox()
boolean RemoveParent()
boolean RemoveComponent(Component|string component)
Component? GetComponentByType(string typeName)
Find a component by type name. Returns the first component found
Component[] GetComponentsByType(string typeName)
Find all components by type name
Component? GetComponent(string typeName)
Component[] GetComponents(string typeName)
Component AddComponent(string componentType)
Object[] WithChildren(boolean? includeInactive)
get the object and all its children, descendants, does not returns destroyed objects
ScriptInstance FindScript(string name)
Find attached script component lua table by name
ScriptInstance FindScriptWithChildren(string name)
Recursively search this object and all descendants; return the first script with the given name.
Object? FindObjectWithChildren(string|Object find, boolean? includeInactive)
Recursively search this object and all descendants; return the first object matching by name (string) or by identity (Object).
Component? GetComponentWithChildren(string typeName, boolean? includeInactive)
Recursively search this object and all descendants; return the first component of the given type.
Component[] GetComponentsWithChildren(string typeName, boolean? includeInactive)
Recursively collect all components of the given type from this object and all descendants.
boolean HasScript(string name)
number GetVolumeWithChildren(string stopIfChildObjHasScript)
Volume of all the VoxelData components in the object and all its children
string GetNetworkFlow()
string GetScriptUpdateTime()
integer GetRefCount()
Properties
Vec3 pos
The global (world) position of the object
number posX
number posY
number posZ
Quat rot
The global (world) rotation of the object as a quaternion
Vec3 eulerRot
The global (world) rotation of the object represented as Euler angles.
number scale
The global (world) scale of the object.
Vec3 localPos
The local position of the object relative to its parent
Quat localRot
The local rotation of the object represented as a quaternion.
Vec3 localEulerRot
The local rotation of the object represented as Euler angles.
number localScale
The local scale of the object relative to its parent
Vec3 right
The right direction vector of the object in world space.
Vec3 up
The up direction vector of the object in world space.
Vec3 forward
The forward direction vector of the object in world space.
number transformFingerprint
64-bit value that changes when the object's global (world) position, rotation, or scale change — including motion caused by an ancestor moving. Useful for cheap change detection.
string name
boolean active
Set the object to be active or inactive. Inactive objects are not updated or rendered. All its children also become inactive.
boolean activeInHierarchy
Readonly. Check if the object is active in the scene. It may be inactive because a parent is inactive.
boolean save
Save this object in the hierarchy. If not saved it will be deleted after lua reset or server restart
boolean isDestroyed
True if the object was destroyed. Note that references to this object will still be valid
string id
This is id is unique across clients and server
Object? parent
Object[] children
integer subtreeVersion
Monotonic counter bumped on this object and all of its ancestors whenever a child is added, removed, or reordered anywhere in its subtree (parent/unparent/reorder). Does NOT change for transform edits (use transformFingerprint) or component add/remove. Cheap O(1) check for invalidating caches derived from the child hierarchy, e.g. WithChildren().
integer siblingIndex
This object's position among its parent's children.