add item.caption(...) function & move item library docs to libitem.md
This commit is contained in:
parent
57e397e692
commit
4dfa235f12
@ -10,6 +10,7 @@ Subsections:
|
|||||||
- [Entities and components](scripting/ecs.md)
|
- [Entities and components](scripting/ecs.md)
|
||||||
- [Libraries](#)
|
- [Libraries](#)
|
||||||
- [block](scripting/builtins/libblock.md)
|
- [block](scripting/builtins/libblock.md)
|
||||||
|
- [item](scripting/builtins/libitem.md)
|
||||||
- [entities](scripting/builtins/libentities.md)
|
- [entities](scripting/builtins/libentities.md)
|
||||||
- [cameras](scripting/builtins/libcameras.md)
|
- [cameras](scripting/builtins/libcameras.md)
|
||||||
- [mat4](scripting/builtins/libmat4.md)
|
- [mat4](scripting/builtins/libmat4.md)
|
||||||
@ -306,38 +307,6 @@ inventory.move(invA: int, slotA: int, invB: int, slotB: int)
|
|||||||
Move item from slotA of invA to slotB of invB. invA may be the same as invB.
|
Move item from slotA of invA to slotB of invB. invA may be the same as invB.
|
||||||
If slotB will be chosen automaticly if argument is not specified.
|
If slotB will be chosen automaticly if argument is not specified.
|
||||||
|
|
||||||
## *item* library
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.name(itemid: int) -> str
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns item string ID (name) by index
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.index(name: str) -> int
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns item integer ID (index) by name
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.stack_size(itemid: int) -> int
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns max stack size for the item
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.defs_count() -> int
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns count of available item IDs.
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.icon(itemid: int) -> str
|
|
||||||
```
|
|
||||||
|
|
||||||
Returns item icon name to use in 'src' property of an image element
|
|
||||||
|
|
||||||
## *hud* library
|
## *hud* library
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ block.index(name: str) -> int
|
|||||||
-- Returns the id of the block material.
|
-- Returns the id of the block material.
|
||||||
block.material(blockid: int) -> str
|
block.material(blockid: int) -> str
|
||||||
|
|
||||||
-- Returns the block name displayed in the UI.
|
-- Returns the block display name.
|
||||||
block.caption(blockid: int) -> str
|
block.caption(blockid: int) -> str
|
||||||
|
|
||||||
-- Returns integer ID by block position
|
-- Returns integer ID by block position
|
||||||
|
|||||||
21
doc/en/scripting/builtins/libitem.md
Normal file
21
doc/en/scripting/builtins/libitem.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# *item* library
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Returns item string ID (name) by index
|
||||||
|
item.name(itemid: int) -> str
|
||||||
|
|
||||||
|
-- Returns item integer ID (index) by name
|
||||||
|
item.index(name: str) -> int
|
||||||
|
|
||||||
|
-- Returns the item display name.
|
||||||
|
block.caption(blockid: int) -> str
|
||||||
|
|
||||||
|
-- Returns max stack size for the item
|
||||||
|
item.stack_size(itemid: int) -> int
|
||||||
|
|
||||||
|
-- Returns count of available item IDs.
|
||||||
|
item.defs_count() -> int
|
||||||
|
|
||||||
|
-- Returns item icon name to use in 'src' property of an image element
|
||||||
|
item.icon(itemid: int) -> str
|
||||||
|
```
|
||||||
@ -10,6 +10,7 @@
|
|||||||
- [Сущности и компоненты](scripting/ecs.md)
|
- [Сущности и компоненты](scripting/ecs.md)
|
||||||
- [Библиотеки](#)
|
- [Библиотеки](#)
|
||||||
- [block](scripting/builtins/libblock.md)
|
- [block](scripting/builtins/libblock.md)
|
||||||
|
- [item](scripting/builtins/libitem.md)
|
||||||
- [entities](scripting/builtins/libentities.md)
|
- [entities](scripting/builtins/libentities.md)
|
||||||
- [cameras](scripting/builtins/libcameras.md)
|
- [cameras](scripting/builtins/libcameras.md)
|
||||||
- [mat4](scripting/builtins/libmat4.md)
|
- [mat4](scripting/builtins/libmat4.md)
|
||||||
@ -288,38 +289,6 @@ inventory.move(invA: int, slotA: int, invB: int, slotB: int)
|
|||||||
invA и invB могут указывать на один инвентарь.
|
invA и invB могут указывать на один инвентарь.
|
||||||
slotB будет выбран автоматически, если не указывать явно.
|
slotB будет выбран автоматически, если не указывать явно.
|
||||||
|
|
||||||
## Библиотека item
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.name(itemid: int) -> str
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает строковый id предмета по его числовому id (как block.name)
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.index(name: str) -> int
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает числовой id предмета по строковому id (как block_index)
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.stack_size(itemid: int) -> int
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает максимальный размер стопки для предмета.
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.defs_count() -> int
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает общее число доступных предметов (включая сгенерированные)
|
|
||||||
|
|
||||||
```python
|
|
||||||
item.icon(itemid: int) -> str
|
|
||||||
```
|
|
||||||
|
|
||||||
Возвращает имя иконки предмета для использования в свойстве 'src' элемента image
|
|
||||||
|
|
||||||
## Библиотека hud
|
## Библиотека hud
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
23
doc/ru/scripting/builtins/libitem.md
Normal file
23
doc/ru/scripting/builtins/libitem.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Библиотека *item*
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Возвращает строковый id предмета по его числовому id (как block.name)
|
||||||
|
item.name(itemid: int) -> str
|
||||||
|
|
||||||
|
-- Возвращает числовой id предмета по строковому id (как block_index)
|
||||||
|
item.index(name: str) -> int
|
||||||
|
|
||||||
|
-- Возвращает название предмета, отображаемое в интерфейсе.
|
||||||
|
item.caption(blockid: int) -> str
|
||||||
|
|
||||||
|
-- Возвращает максимальный размер стопки для предмета.
|
||||||
|
item.stack_size(itemid: int) -> int
|
||||||
|
|
||||||
|
-- Возвращает общее число доступных предметов (включая сгенерированные)
|
||||||
|
item.defs_count() -> int
|
||||||
|
|
||||||
|
-- Возвращает имя иконки предмета для использования в свойстве 'src' элемента image
|
||||||
|
item.icon(itemid: int) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -47,6 +47,13 @@ static int l_item_get_icon(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_item_caption(lua::State* L) {
|
||||||
|
if (auto def = get_item_def(L, 1)) {
|
||||||
|
return lua::pushstring(L, def->caption);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg itemlib[] = {
|
const luaL_Reg itemlib[] = {
|
||||||
{"index", lua::wrap<l_item_index>},
|
{"index", lua::wrap<l_item_index>},
|
||||||
{"name", lua::wrap<l_item_name>},
|
{"name", lua::wrap<l_item_name>},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user