Add on_entity_spawned and on_entity_despawned events

This commit is contained in:
Xertis 2026-04-04 01:53:49 +03:00
parent 936a5c8525
commit 518d5d5ae4
8 changed files with 75 additions and 1 deletions

View file

@ -180,6 +180,10 @@ rig:get_color() -> vec3
rig:set_color(color: vec3)
```
> [!WARNING]
> When an entity moves outside the loaded area, it is removed, triggering the event.
> When it re-enters the loaded area, the entity is spawned again.
## Component events
```lua

View file

@ -152,6 +152,17 @@ function on_block_interact(blockid, x, y, z, playerid) -> bool
Called on block RMB click interaction. Prevents block placing if **true** returned.
```lua
function on_entity_spawned(uid)
```
Called after an entity is spawned.
```lua
function on_entity_despawned(uid)
```
Called after an entity is removed. At the time of the call, the entity with the given uid has already been deleted.
### Chunk Events (world.lua)
```lua