From 36825d33d14610f70e019ee23c2e1c64a0992f81 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 19 Oct 2026 22:05:26 +0300 Subject: [PATCH] update doc/*/item-properties.md --- doc/en/item-properties.md | 39 +++++++++++++++++++++++++++++++++++++++ doc/ru/item-properties.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/doc/en/item-properties.md b/doc/en/item-properties.md index 44e8911cc..7913aff3f 100644 --- a/doc/en/item-properties.md +++ b/doc/en/item-properties.md @@ -72,6 +72,45 @@ Property status is displayed in the inventory interface. Display method is defin Defines the name of the script containing the item's event handlers. By default, equals to the item's string id (name). Allows you to reuse a single script for multiple items. +## User properties + +Access to custom item properties is provided through the table `item.properties[id]["property"]`, where `id` is the numeric item index. + +User properties must be declared in `pack:config/user-props.toml`: + +```toml +"pack:property_name" = {} +``` + +### Example usage in Lua - `base_survival:tool` + +```lua +local tool = item.properties[itemid]["base_survival:tool"] +if tool then + local stone_material = tool.materials['base:stone'] + if stone_material then + print(tool.type, stone_material.speed) + end +end +``` + +Definition in item JSON: + +```json +{ + "base_survival:tool": { + "type": "breaker", + "materials": { + "base:stone": { + "speed": 15.0 + } + } + } +} +``` + +Custom property tables follow the same inheritance and override rules as block properties. + ## Tags Tags allow you to designate general properties of items. Names should be formatted as `prefix:tag_name`. diff --git a/doc/ru/item-properties.md b/doc/ru/item-properties.md index 1f4be05be..6c170e527 100644 --- a/doc/ru/item-properties.md +++ b/doc/ru/item-properties.md @@ -71,6 +71,45 @@ Определяет имя скрипта, содержащего обработчики событий предмета. По умолчанию соответствует строковому id (имени) предмета. Свойство обеспечивает возможность использования одного скрипта для нескольких предметов. +## Пользовательские свойства + +Доступ к пользовательским свойствам предметов осуществляется через таблицу `item.properties[id]["свойство"]`, где `id` — числовой индекс предмета. + +Пользовательские свойства должны быть объявлены в файле `пак:config/user-props.toml`: + +```toml +"пак:имя_свойства" = {} +``` + +### Пример использования в Lua - `base_survival:tool` + +```lua +local tool = item.properties[itemid]["base_survival:tool"] +if tool then + local stone_material = tool.materials['base:stone'] + if stone_material then + print(tool.type, stone_material.speed) + end +end +``` + +Описание в JSON предмета: + +```json +{ + "base_survival:tool": { + "type": "breaker", + "materials": { + "base:stone": { + "speed": 15.0 + } + } + } +} +``` + +Пользовательские свойства следуют тем же правилам наследования и переопределения, что и свойства блоков. + ## Теги - *tags* Теги позволяют обозначать обобщённые свойства предметов. Названия следует формировать как `префикс:имя_тега`.