diff --git a/doc/en/scripting/events.md b/doc/en/scripting/events.md index 45b8969b..186943f9 100644 --- a/doc/en/scripting/events.md +++ b/doc/en/scripting/events.md @@ -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:`. diff --git a/doc/ru/scripting/events.md b/doc/ru/scripting/events.md index f3a3045b..d6795b26 100644 --- a/doc/ru/scripting/events.md +++ b/doc/ru/scripting/events.md @@ -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:`.