Merge pull request #568 from GHOST3118/improve-items

Improve items
This commit is contained in:
MihailRis
2025-07-26 18:43:37 +03:00
committed by GitHub
14 changed files with 247 additions and 57 deletions
+8
View File
@@ -18,6 +18,14 @@ Name of the item model. The model will be loaded automatically.
Default value is `packid:itemname.model`.
If the model is not specified, an automatic one will be generated.
### Caption and Description
`caption` - name of item in inventory
`description` - item description in inventory
this props allow to use `md`
*see [Text Styles](/doc/en/text-styles.md)*
## Behaviour
### *placing-block*
+34
View File
@@ -97,6 +97,40 @@ inventory.set(...)
inventory.set_all_data(...)
```
for moving is inefficient, use inventory.move or inventory.move_range.
```lua
-- Get item caption
inventory.get_caption(
-- id of inventory
invid: int,
-- slot id
slot: int
)
-- Set item caption
inventory.set_caption(
-- id of inventory
invid: int,
-- slot id
slot: int,
-- Item Caption
caption: string
)
-- Get item description
inventory.get_description(
-- id of inventory
invid: int,
-- slot id
slot: int
)
-- Set item description
inventory.set_description(
-- id of inventory
invid: int,
-- slot id
slot: int,
-- Item Description
description: string
)
```
```lua
-- Returns a copy of value of a local property of an item by name or nil.
+3
View File
@@ -10,6 +10,9 @@ item.index(name: str) -> int
-- Returns the item display name.
block.caption(blockid: int) -> str
-- Returns the item display description.
item.description(itemid: int) -> str
-- Returns max stack size for the item
item.stack_size(itemid: int) -> int
+8
View File
@@ -17,6 +17,14 @@
Значение по-умолчанию - `packid:itemname.model`.
Если модель не указана, будет сгенерирована автоматическию
### Имя и Описание
`caption` - имя предмета в инвентаре
`description` - описание предмета в инвентаре
Можно использовать `md`
*см. [Text Styles](/doc/en/text-styles.md)*
## Поведение
### Устанавливаемый блок - `placing-block`
+34
View File
@@ -94,6 +94,40 @@ inventory.set(...)
inventory.set_all_data(...)
```
для перемещения вляется неэффективным, используйте inventory.move или inventory.move_range.
```lua
-- Получает имя предмета в слоте
inventory.get_caption(
-- id инвентаря
invid: int,
-- индекс слота
slot: int
)
-- Задает имя предмету в слоте
inventory.set_caption(
-- id инвентаря
invid: int,
-- индекс слота
slot: int,
-- Имя предмета
caption: string
)
-- Получает описание предмета в слоте
inventory.get_description(
-- id инвентаря
invid: int,
-- индекс слота
slot: int
)
-- Задает описание предмету в слоте
inventory.set_description(
-- id инвентаря
invid: int,
-- индекс слота
slot: int,
-- Описание предмета
description: string
)
```
```lua
-- Проверяет наличие локального свойства по имени без копирования его значения.
+3
View File
@@ -10,6 +10,9 @@ item.index(name: str) -> int
-- Возвращает название предмета, отображаемое в интерфейсе.
item.caption(itemid: int) -> str
-- Возвращает описание предмета, отображаемое в интерфейсе.
item.description(itemid: int) -> str
-- Возвращает максимальный размер стопки для предмета.
item.stack_size(itemid: int) -> int