mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 09:29:44 +00:00
update doc/*/item-properties.md
This commit is contained in:
parent
aab363cfb7
commit
36825d33d1
2 changed files with 78 additions and 0 deletions
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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*
|
||||
|
||||
Теги позволяют обозначать обобщённые свойства предметов. Названия следует формировать как `префикс:имя_тега`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue