Entity
| Property | Type | Writable | Description |
|---|---|---|---|
NetworkId | number | Read-only | Temporary but unique network ID of this entity. |
CustomData | ManagedLuaTable | Read-only | Managed table for storing data on this entity. |
EntityDefinition | Read-only | Registry definition of this entity. | |
Name | string | Writable | Name of this entity. Not necessarily unique.null |
Coordinate | Read-only | Coordinate this entity is located at. | |
Facing | Direction | Read-only | Direction this entity is facing. |
Dimension | Read-only | Dimension this entity is located in. | |
Map | Read-only | Map layer tree this entity is located on, derived from its dimension. | |
CollisionViewer | CollisionViewer | Read-only | Viewer based on this entity's collision flags. |
VisionViewer | VisionViewer | Read-only | Viewer based on this entity's vision flags. |
| Function |
|---|
Spawn()Spawn(dimension: Dimension) |
Spawns the entity in a dimension, making it visible to players. |
Despawn() |
Despawns the entity, removing it from its dimension. |
Remove() |
Permanently removes the entity from the world. |
Ref(): LuaReference |
Creates a safe reference to this entity that can be stored in CustomData. |
SetCoordinate(coordinate: Coordinate) |
Sets the entity's coordinate and teleports it to the new position. |
SetFacing(direction: Direction) |
Sets the entity's facing direction. |
Move(direction: Direction): boolean |
Moves the entity one step in the specified direction.
Returns true if the move was successful, false if blocked. |
SetVision(enabled: boolean)SetVision(enabled: boolean, tag: string) |
Sets whether the entity can see objects with a specific vision tag. |
HasVision(): booleanHasVision(tag: string): boolean |
Checks if the entity has vision for a specific tag. |
GrantVision()GrantVision(tag: string) |
Grants the entity vision for a specific tag. |
RevokeVision()RevokeVision(tag: string) |
Revokes the entity's vision for a specific tag. |
SetVisibility(enabled: boolean)SetVisibility(enabled: boolean, tag: string) |
Sets whether the entity is visible to objects with a specific vision tag. |
IsVisible(): booleanIsVisible(tag: string): boolean |
Checks if the entity is visible for a specific tag. |
IsInvisible(): booleanIsInvisible(tag: string): boolean |
Checks if the entity is invisible for a specific tag. |
MakeVisible()MakeVisible(tag: string) |
Makes the entity visible for a specific tag. |
MakeInvisible()MakeInvisible(tag: string) |
Makes the entity invisible for a specific tag. |
HasCollisions(): booleanHasCollisions(tag: string): boolean |
Checks if the entity has collision enabled for a specific tag. |
SetCollisions(enabled: boolean)SetCollisions(enabled: boolean, tag: string) |
Sets whether the entity has collision for a specific tag. |
EnableCollisions()EnableCollisions(tag: string) |
Enables collision for the entity with a specific tag. |
DisableCollisions()DisableCollisions(tag: string) |
Disables collision for the entity with a specific tag. |
AddDynamicComponent(name: string, callback: function()) |
Adds a dynamic component that is resolved per-player using a callback function. |
GetControllingPlayers(): table<Player> |
Gets all players that are currently controlling this entity. |
GetAttribute(name: string): Attribute | nil |
Gets an attribute by name from this entity. |
CreateAttribute(name: string, initialValue: any): Attribute |
Creates a new attribute on this entity with an initial value. |
HasTag(tag: string): boolean |
Checks if the entity has a specific tag in its definition. |
PlayAnimation(animationName: string) |
Plays an animation on this entity for all watching players. |