Builtin Library
README.md
prefab.entity (procNode)
Add a child entity to a prefab, the reusable entity template a spawn copies, hung under the root or under a named entity. The child has no components and the identity pose. prefab.add_component writes to the root only, so a child that needs components is written whole with prefab.record and joined on with prefab.edit (what = "join"). The parts a graph builds and parents itself are elements: elements.entity makes one and elements.link parents it under another.
The new record's id is add_<n>, n being the number of records the prefab held before it. Built from prefab.edit (what = "entity").
Inputs
prefab(Prefab). The prefab the child is added to. It comes out as a new value; the prefab wired in keeps the shape it had.name(String, default "child"). The new entity's name, and the handle every later name lookup reaches it by. Names may repeat, and a lookup takes the first record carrying one. An empty string takes "child".parent(String, optional). The name of the entity the child hangs 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 car = g.prefab.entity({ prefab = g.prefab.empty({ name = "car" }), name = "wheel" })
car = g.prefab.entity({ prefab = car, name = "hub", parent = "wheel" })