Caffeine

Hierarchy

Reference Core Last updated: Lua 6 · Dryad 6

Parent and child links between entities. A child's transform is composed with its parent's.

All namespaces

Namespace: caffeine.hierarchy · Dryad prefix: caffeine_hierarchy_

parent#

Lua: caffeine.hierarchy.parent · Dryad: caffeine_hierarchy_parent

text
parent(entity) -> number

Returns the parent of an entity.

ParametersTypeDescription
entitynumberThe entity id.

Returns: number. The parent id, or 0 when it has none.

Example

lua
local p = caffeine.hierarchy.parent(eid)

setParent#

Lua: caffeine.hierarchy.setParent · Dryad: caffeine_hierarchy_set_parent

text
setParent(entity, parent) -> boolean

Attaches an entity under another.

ParametersTypeDescription
entitynumberThe child.
parentnumberThe 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

lua
caffeine.hierarchy.setParent(wheel, car)

detach#

Lua: caffeine.hierarchy.detach · Dryad: caffeine_hierarchy_detach

text
detach(entity) -> boolean

Removes the parent link.

ParametersTypeDescription
entitynumberThe entity id.

Returns: boolean. false when the entity is dead.

Example

lua
caffeine.hierarchy.detach(wheel)

children#

Lua: caffeine.hierarchy.children · Dryad: caffeine_hierarchy_children

text
children(entity) -> table

Lists the direct children of an entity.

ParametersTypeDescription
entitynumberThe entity id.

Returns: table. Array of direct child ids, ascending.

Example

lua
for _, c in ipairs(caffeine.hierarchy.children(car)) do end

childCount#

Lua: caffeine.hierarchy.childCount · Dryad: caffeine_hierarchy_child_count

text
childCount(entity) -> number

Counts the direct children.

ParametersTypeDescription
entitynumberThe entity id.

Returns: number. Number of direct children.

Example

lua
local n = caffeine.hierarchy.childCount(car)

root#

Lua: caffeine.hierarchy.root · Dryad: caffeine_hierarchy_root

text
root(entity) -> number

Walks up to the top of the hierarchy.

ParametersTypeDescription
entitynumberThe entity id.

Returns: number. The topmost ancestor (the entity itself when it has no parent).

Example

lua
local top = caffeine.hierarchy.root(wheel)