mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Add on_entity_spawned and on_entity_despawned events
This commit is contained in:
parent
936a5c8525
commit
518d5d5ae4
8 changed files with 75 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -180,6 +180,10 @@ rig:get_color() -> vec3
|
|||
rig:set_color(color: vec3)
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> При выходе сущности за пределы зоны прогрузки она удаляется, вызывая события.
|
||||
> При повторном попадании в зону прогрузки сущность спавнится заново.
|
||||
|
||||
## События компонента
|
||||
|
||||
```lua
|
||||
|
|
|
|||
|
|
@ -156,6 +156,18 @@ function on_block_interact(blockid, x, y, z, playerid) -> bool
|
|||
|
||||
Вызывается при нажатии на блок ПКМ. Предотвращает установку блоков, если возвращает `true`
|
||||
|
||||
```lua
|
||||
function on_entity_spawned(uid)
|
||||
```
|
||||
|
||||
Вызывается после спавна сущности
|
||||
|
||||
```lua
|
||||
function on_entity_despawned(uid)
|
||||
```
|
||||
|
||||
Вызывается после удаления сущности, на момент вызова события сущность с переданным uid уже удалена
|
||||
|
||||
```lua
|
||||
function on_player_tick(playerid: int, tps: int)
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue