From 918cb8aa329180f7fa650cfeb18e453f89994cb1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 12 Jan 2025 19:43:06 +0300 Subject: [PATCH] update doc/*/scripting/events.md --- doc/en/scripting/events.md | 28 ++++++++++++++++++++++++++++ doc/ru/scripting/events.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/doc/en/scripting/events.md b/doc/en/scripting/events.md index cc820898..21e1cee5 100644 --- a/doc/en/scripting/events.md +++ b/doc/en/scripting/events.md @@ -126,6 +126,34 @@ function on_block_interact(blockid, x, y, z, playerid) -> bool Called on block RMB click interaction. Prevents block placing if **true** returned. +### Chunk Events (world.lua) + +```lua +function on_chunk_present(x: int, z: int, loaded: bool) +``` + +Called after a chunk is generated/loaded. If a previously saved chunk is loaded, `loaded` will be true. + +```lua +function on_chunk_remove(x: int, z: int) +``` + +Called when a chunk is unloaded from the world. + +### Inventory Events (world.lua) + +```lua +function on_inventory_open(invid: int, playerid: int) +``` + +Called when the inventory is opened. If the inventory was not opened directly by the player, playerid will be -1. + +```lua +function on_inventory_closed(invid: int, playerid: int) +``` + +Called when the inventory is closed. + ## Layout events Script *layouts/layout_name.xml.lua* events. diff --git a/doc/ru/scripting/events.md b/doc/ru/scripting/events.md index a5cc3e72..c7781879 100644 --- a/doc/ru/scripting/events.md +++ b/doc/ru/scripting/events.md @@ -126,6 +126,35 @@ function on_block_interact(blockid, x, y, z, playerid) -> bool Вызывается при нажатии на блок ПКМ. Предотвращает установку блоков, если возвращает `true` +### События чанков (world.lua) + +```lua +function on_chunk_present(x: int, z: int, loaded: bool) +``` + +Вызывается после генерации/загрузки чанка. В случае загрузки ранее сохраненного чанка `loaded` будет истинным. + +```lua +function on_chunk_remove(x: int, z: int) +``` + +Вызывается при выгрузке чанка из мира. + +### События инвентарей (world.lua) + +```lua +function on_inventory_open(invid: int, playerid: int) +``` + +Вызывается при открытии инвентаря. Если инвентарь был открыт не напрямую игроком, playerid будет равен -1. + +```lua +function on_inventory_closed(invid: int, playerid: int) +``` + +Вызывается при закрытии инвентаря. + + ## События макета События прописываются в файле `layouts/имя_макета.xml.lua`.