Merge pull request #826 from Xertis/dev

Add on_entity_spawned and on_entity_despawned events
This commit is contained in:
MihailRis 2026-04-08 23:32:01 +03:00 • committed by GitHub
commit ce32a25d31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 61 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_spawn(uid)
```
Called after an entity is spawned.
```lua
function on_entity_despawn(uid)
```
Called before an entity is despawned.
### Chunk Events (world.lua)
```lua

View file

@ -180,6 +180,10 @@ rig:get_color() -> vec3
rig:set_color(color: vec3)
```
> [!WARNING]
> При выходе сущности за пределы зоны прогрузки она удаляется, вызывая события.
> При повторном попадании в зону прогрузки сущность спавнится заново.
## События компонента
```lua

View file

@ -156,6 +156,18 @@ function on_block_interact(blockid, x, y, z, playerid) -> bool
Вызывается при нажатии на блок ПКМ. Предотвращает установку блоков, если возвращает `true`
```lua
function on_entity_spawn(uid)
```
Вызывается после спавна сущности
```lua
function on_entity_despawn(uid)
```
Вызывается перед удалением сущности
```lua
function on_player_tick(playerid: int, tps: int)
```