Hierarchy
Parent and child links between entities. A child's transform is composed with its parent's.
Namespace: caffeine.hierarchy · Dryad prefix: caffeine_hierarchy_
parent#
Lua: caffeine.hierarchy.parent · Dryad: caffeine_hierarchy_parent
parent(entity) -> number
Returns the parent of an entity.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: number. The parent id, or 0 when it has none.
Example
local p = caffeine.hierarchy.parent(eid)
setParent#
Lua: caffeine.hierarchy.setParent · Dryad: caffeine_hierarchy_set_parent
setParent(entity, parent) -> boolean
Attaches an entity under another.
| Parameters | Type | Description |
|---|---|---|
entity | number | The child. |
parent | number | The new parent; 0 detaches. |
Returns: boolean. false when either entity is dead, the parent is the entity itself, or the link would create a cycle.
Example
caffeine.hierarchy.setParent(wheel, car)
detach#
Lua: caffeine.hierarchy.detach · Dryad: caffeine_hierarchy_detach
detach(entity) -> boolean
Removes the parent link.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: boolean. false when the entity is dead.
Example
caffeine.hierarchy.detach(wheel)
children#
Lua: caffeine.hierarchy.children · Dryad: caffeine_hierarchy_children
children(entity) -> table
Lists the direct children of an entity.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: table. Array of direct child ids, ascending.
Example
for _, c in ipairs(caffeine.hierarchy.children(car)) do end
childCount#
Lua: caffeine.hierarchy.childCount · Dryad: caffeine_hierarchy_child_count
childCount(entity) -> number
Counts the direct children.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: number. Number of direct children.
Example
local n = caffeine.hierarchy.childCount(car)
root#
Lua: caffeine.hierarchy.root · Dryad: caffeine_hierarchy_root
root(entity) -> number
Walks up to the top of the hierarchy.
| Parameters | Type | Description |
|---|---|---|
entity | number | The entity id. |
Returns: number. The topmost ancestor (the entity itself when it has no parent).
Example
local top = caffeine.hierarchy.root(wheel)