Skip to main content

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.

DespawnBefore

this.DespawnBefore(parent)

Causes this to be despawned just before parent is despawned, whenever that occurs.

Exists

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 things in the middle of processing can cause problems, so this is a safer way to do it.

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 to Category:All.
  • against (Flags) and owner (Entity): The alliance status between each entity and owner must overlap at least one of these alliance flags. Defaults to Alliance:All.

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 to Category:All.
  • against (Flags) and owner (Entity): The alliance status between the entity and owner must overlap at least one of these alliance flags. Defaults to Alliance:All.

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 to Category:All.
  • against (Flags) and owner (Entity): The alliance status between each entity and owner must overlap at least one of these alliance flags. Defaults to Alliance:All.

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, executing the delve block as its main behavior. When the entity despawns, all of its behaviors will be terminated.

The main behavior block will execute concurrently with the rest of the game. This function will return as soon as its delve block 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 delve block is executed as the main behavior of the new entity. When the entity despawns, all of its behaviors will be terminated.

The main behavior block will execute concurrently with the rest of the game. This function will return as soon as its delve block reaches an await and goes to sleep.

Subspawn

this.Subspawn |use this = entity| { } -> entity

Spawns a new subentity with this as its parent, executing the delve block as its main behavior. If parent despawns, the subentity will be despawned first.

The main behavior block 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. The delve block is executed as the main behavior of the new entity. If parent despawns, the subentity will be despawned first.

The main behavior block 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.

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.