Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit44fd9e59bd

README.md

entityOps.duplicate

Copy entities that already exist — one duplicate, or a numbered run of them spread along an axis.

entityOps.duplicate("crate")
entityOps.duplicate("crate", { count = 5, offset = { 2, 0, 0 } })
entityOps.duplicate("pillar", { count = 4, offset = { 0, 3, 0 }, name = "pillar_%d" })
entityOps.duplicate({ name = { "tree" } }, { offset = { 10, 0, 0 } })

Targets take a name or id, a list of them, scene.find records, or a query resolved for you — so everything matching { name = { "tree" } } is copied without looking the entities up first.

count makes that many copies of each source. It must be a whole number of at least 1.

offset is a world-space {x,y,z} step that accumulates: copy 1 sits one offset from the source, copy 2 sits two, copy 3 sits three. Every copy is placed relative to the source, so a run spreads evenly instead of compounding rounding from copy to copy.

name names each copy, and a %d in it becomes the copy's 1-based index — "pillar_%d" yields pillar_1, pillar_2, … Without a name, copies are named after their source (crate_copy, or crate_copy_1, crate_copy_2, … for a run).

Copies carry the source's render layer.

An option key outside the documented set is an error that names it and lists the accepted keys, so a mistyped conut is reported instead of returning copies that quietly ignored it.

Every call returns the resulting { id, name, position, localPosition, rotation, localRotation, eulerAngles, scale, parent } per copy, in creation order — the copy and the read are the same call.