CreateMapPrefab
Places a prefab as one unit - one map object drawn as the prefab’s objects, that follows the prefab.
PlaceMapPrefab copies a prefab’s objects into new map objects, each sent, saved and tracked on its own. A unit is one map
object (mesh "prefab:<name>"): one record on the network, in the map’s files and in an undo, that every player’s game and the
server draw as the prefab’s objects at its place, turn and scale - a village of eighty houses is eighty records, not two thousand.
It follows its prefab: saving the prefab again (SaveMapPrefab, the editor’s “Save as prefab”) changes every unit of it at
once. Its objects are solid, have their doors, seats, lights and use prompts, and stand in the server’s collision and navmesh as
if placed one by one; each has an id of its own, the same in every game and after a restart (GetMapPrefabParts) - a door’s key,
the id OnPlayerUseMapObject names. They are changed through the unit: move, turn, scale (one number), solid, view, lod,
layer with SetMapObject on the unit’s id; to change one of them, UnpackMapPrefab first.
A prefab used by a unit cannot be deleted; a unit holds no web surface board. Every object of a unit counts toward the map’s
10,000. SetMapObject and CreateMapObject with "prefab:<name>" as the mesh make and change units too. Admins: /map prefab unit <name>; the map editor’s prefab list places units with “As one unit”.
Syntax
Section titled “Syntax”CreateMapPrefab(name, x, y, z [, opts])| Parameter | Type | |
|---|---|---|
name |
string | the prefab |
x |
number | metres - where its pivot goes |
y |
number | metres |
z |
number | metres; below 0 = on the ground |
opts |
table | as CreateMapObject’s: yaw, pitch, roll, scale (one number), solid (false: none of its objects is), view, lod (over its objects’ own; 0 = theirs), layer, group, persist, attach (optional) |
Returns
Section titled “Returns”number - the unit’s id; nil and the reason
Example
Section titled “Example”-- a street of houses, each one recordfor i = 0, 9 do CreateMapPrefab("house_a", 1200 + i * 14, 1050, -1, {yaw = 90}) endSee also
Section titled “See also”GetMapPrefabParts · UnpackMapPrefab · SaveMapPrefab · PlaceMapPrefab · the The server’s map group of the index
