Entities
BeforeDespawn
await this.BeforeDespawn
Waits until just before the entity is despawned.
Despawn
this.Despawn -> boolean
Immediately despawns the entity, removing it from the world.
Returns true if this still exists and was just despawned.
Returns false if this does not exist or is nullish.
DespawnBefore
this.DespawnBefore(parent)
Causes this to be despawned just before parent is despawned,
whenever that occurs.
An entity can have multiple parents. Each call to DespawnBefore adds another parent.
The entity will despawn whenever the first of its parents despawns.
Exists
this.Exists -> boolean
Exists(this) -> boolean
Returns true if the entity still exists, false if it has been despawned or is not an entity.
Expire
this.Expire
Registers to despawn this entity in the next reap phase, which is normally later in the tick.
Sometimes despawning an entity in the middle of processing can cause problems,
as there may be currently-executing code that is still using the entity.
This is sometimes a safer than calling Despawn directly.
Query
Query(filter?, against?=, [owner?]) -> array
Returns an array of all entities that match the given criteria.
-
filter(Categories): Each entity's Category must overlap at least one of these categories. Defaults toCategory:All. -
against(Flags): Filters entities based on their alliance status withowner. For an entity to match, the alliance status between theownerparameter and the Owner of the Entity must overlap withagainst. Defaults toAlliance:All. See Alliance flags for all possible values. -
owner(Entity): The player who is performing the query. Affects how theagainstfilter is interpreted.
Only entities with their Category property assigned
will be considered by this function, even if filter is Category:All.
If no entities match, returns an empty array.
QueryAny
QueryAny(filter?, against?=, [owner?]) -> entity
Finds the first entity that matches the given criteria.
-
filter(Categories): The entity's Category must overlap at least one of these categories. Defaults toCategory:All. -
against(Flags): Filters entities based on their alliance status withowner. For an entity to match, the alliance status between theownerparameter and the Owner of the Entity must overlap withagainst. Defaults toAlliance:All. See Alliance flags for all possible values. -
owner(Entity): The player who is performing the query. Affects how theagainstfilter is interpreted.
Only entities with their Category property assigned
will be considered by this function, even if filter is Category:All.
If no entity matches, returns undefined.
QueryCount
QueryCount(filter?, against?=, [owner?]) -> number
Returns the Number of entities that match the given criteria.
-
filter(Categories): Each entity's Category must overlap at least one of these categories. Defaults toCategory:All. -
against(Flags): Filters entities based on their alliance status withowner. For an entity to match, the alliance status between theownerparameter and the Owner of the Entity must overlap withagainst. Defaults toAlliance:All. See Alliance flags for all possible values. -
owner(Entity): The player who is performing the query. Affects how theagainstfilter is interpreted.
Only entities with their Category property assigned
will be considered by this function, even if filter is Category:All.
Spawn
Spawn |use this = entity| { } -> entity
Spawns a new entity.
The subblock defines the main behavior for the entity. The main behavior block will execute concurrently with the rest of the game. When the entity despawns, its main behavior will be terminated (along with all other behaviors attached to the entity).
This function will return as soon as the subblock reaches an await and goes to sleep.
await Spawn |use this = entity| { }
Spawns a new entity, then waits for it to despawn before continuing.
The subblock defines the main behavior for the entity. The main behavior block will execute concurrently with the rest of the game. When the entity despawns, its main behavior will be terminated (along with all other behaviors attached to the entity).
Subspawn
this.Subspawn |use this = entity| { } -> entity
Spawns a new subentity with this as its parent.
When the parent despawns, the subentity will be despawned first.
The subblock defines the main behavior for the new entity, and will execute concurrently with the rest of the game. When the subentity despawns, all of its behaviors will be terminated.
This function returns as soon as its delve block reaches an await and goes to sleep.
await this.Subspawn |use this = entity| { }
Spawns a new subentity with this as its parent,
then waits for it to despawn before continuing.
When the parent despawns, the subentity will be despawned first.
The subblock defines the main behavior for the new entity, and will execute concurrently with the rest of the game. When the subentity despawns, all of its behaviors will be terminated.
World
World -> entity
Returns the global entity World.
This entity exists before the game starts and will exist until the game ends.
It can never be despawned.
World can be used to create global properties, behaviors, signals, etc.