update doc/*/item-properties.md

This commit is contained in:
MihailRis 2026-10-19 22:05:26 +03:00
parent aab363cfb7
commit 36825d33d1
2 changed files with 78 additions and 0 deletions

View file

@ -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`.

View file

@ -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*
Теги позволяют обозначать обобщённые свойства предметов. Названия следует формировать как `префикс:имя_тега`.