Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

prefab.parent (procNode)

Set the parent of an entity in a prefab, the reusable entity template a spawn copies, the child and the parent identified by name. Use it to regroup entities after they were added. The parts a graph builds and parents itself are elements: elements.entity makes one and elements.link parents it under another.

Built from prefab.edit (what = "parent").

Inputs

  • prefab (Prefab). The prefab the move happens inside. It comes out as a new value; both names are resolved against this one prefab.
  • child (String, default ""). The name of the entity to move. Every record carrying that name is moved, the root excepted, so a name shared by several children regroups all of them at once; a name the prefab does not carry leaves the hierarchy as it was.
  • parent (String, optional). The name of the entity to hang the child under. Left out, or naming an entity the prefab does not carry, hangs it on the root.

Outputs

  • prefab (Prefab). A new prefab value, { records = { ... } }; the prefab wired in keeps the records it had.
local rig = g.prefab.empty({ name = "rig" })
rig = g.prefab.entity({ prefab = rig, name = "arm" })
rig = g.prefab.entity({ prefab = rig, name = "hand" })
rig = g.prefab.parent({ prefab = rig, child = "hand", parent = "arm" })