entities.create
entities.create(def: { position: Position, kind: string?, name: string?, bucket: number?, props: { [string]: any }? }): Entity
Creates an entity in the world.
| Field | Type | Role |
|---|---|---|
position |
Position |
required: {x, y, z}, {x = 1, y = 2, z = 0} or vector |
kind |
string |
free kind: cauldron, broom… object by default |
name |
string |
name, 64 characters at most |
bucket |
number |
0 by default |
props |
table |
public properties set right away |
Parameters#
- def (
table): see the fields below
Returns#
Entity: the created entity
Example#
local cauldron = entities.create({
kind = "cauldron",
name = "Big cauldron",
position = { 6, 11, 0 },
bucket = 101,
props = { full = true },
})
Notes#
- The entity is deleted when the script stops.
- An error is raised if
world.maxEntitiesis reached.