update doc/*/scripting/events.md

This commit is contained in:
MihailRis 2024-11-01 15:14:25 +03:00
parent 72d5eca632
commit a47bdc0409
2 changed files with 42 additions and 0 deletions

View File

@ -136,3 +136,24 @@ function on_hud_close(playerid: int)
```
Called on world close (before saving)
## *events* library
```lua
events.on(code: str, handler: function)
```
Adds an event handler by its code, not limited to the standard ones.
```lua
events.emit(code: str, args...) -> bool
```
Emits an event by code. If the event does not exist, nothing will happen.
The existence of an event is determined by the presence of handlers.
```lua
events.unload(packid: str)
```
Removes all events with the prefix `packid:`. When you exit the world, events from all packs are unloaded, including `core:`.

View File

@ -135,3 +135,24 @@ function on_hud_close(playerid: int)
```
Вызывается при выходе из мира, перед его сохранением.
## Библиотека *events*
```lua
events.on(code: str, handler: function)
```
Добавляет обработчик события по его коду, не ограничиваясь стандартными.
```lua
events.emit(code: str, args...) -> bool
```
Генерирует событие по коду. Если событие не существует, ничего не произойдет.
Существование события определяется наличием обработчиков.
```lua
events.unload(packid: str)
```
Удаляет все события с префиксом `packid:`. Вы выходе из мира выгружаются события всех паков, включая `core:`.