add item.get_placing_block
This commit is contained in:
parent
db1387d977
commit
751f8a7544
@ -18,4 +18,7 @@ item.defs_count() -> int
|
|||||||
|
|
||||||
-- Returns item icon name to use in 'src' property of an image element
|
-- Returns item icon name to use in 'src' property of an image element
|
||||||
item.icon(itemid: int) -> str
|
item.icon(itemid: int) -> str
|
||||||
|
|
||||||
|
-- Returns the integer id 'placing-block' or 0
|
||||||
|
item.get_placing_block(itemid: int) -> int
|
||||||
```
|
```
|
||||||
|
|||||||
@ -8,7 +8,7 @@ item.name(itemid: int) -> str
|
|||||||
item.index(name: str) -> int
|
item.index(name: str) -> int
|
||||||
|
|
||||||
-- Возвращает название предмета, отображаемое в интерфейсе.
|
-- Возвращает название предмета, отображаемое в интерфейсе.
|
||||||
item.caption(blockid: int) -> str
|
item.caption(itemid: int) -> str
|
||||||
|
|
||||||
-- Возвращает максимальный размер стопки для предмета.
|
-- Возвращает максимальный размер стопки для предмета.
|
||||||
item.stack_size(itemid: int) -> int
|
item.stack_size(itemid: int) -> int
|
||||||
@ -18,6 +18,9 @@ item.defs_count() -> int
|
|||||||
|
|
||||||
-- Возвращает имя иконки предмета для использования в свойстве 'src' элемента image
|
-- Возвращает имя иконки предмета для использования в свойстве 'src' элемента image
|
||||||
item.icon(itemid: int) -> str
|
item.icon(itemid: int) -> str
|
||||||
|
|
||||||
|
-- Возвращает числовой id блока, назначенного как 'placing-block' или 0
|
||||||
|
item.get_placing_block(itemid: int) -> int
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,30 +10,30 @@ static const ItemDef* get_item_def(lua::State* L, int idx) {
|
|||||||
return indices->items.get(id);
|
return indices->items.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_item_name(lua::State* L) {
|
static int l_name(lua::State* L) {
|
||||||
if (auto def = get_item_def(L, 1)) {
|
if (auto def = get_item_def(L, 1)) {
|
||||||
return lua::pushstring(L, def->name);
|
return lua::pushstring(L, def->name);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_item_index(lua::State* L) {
|
static int l_index(lua::State* L) {
|
||||||
auto name = lua::require_string(L, 1);
|
auto name = lua::require_string(L, 1);
|
||||||
return lua::pushinteger(L, content->items.require(name).rt.id);
|
return lua::pushinteger(L, content->items.require(name).rt.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_item_stack_size(lua::State* L) {
|
static int l_stack_size(lua::State* L) {
|
||||||
if (auto def = get_item_def(L, 1)) {
|
if (auto def = get_item_def(L, 1)) {
|
||||||
return lua::pushinteger(L, def->stackSize);
|
return lua::pushinteger(L, def->stackSize);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_item_defs_count(lua::State* L) {
|
static int l_defs_count(lua::State* L) {
|
||||||
return lua::pushinteger(L, indices->items.count());
|
return lua::pushinteger(L, indices->items.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_item_get_icon(lua::State* L) {
|
static int l_get_icon(lua::State* L) {
|
||||||
if (auto def = get_item_def(L, 1)) {
|
if (auto def = get_item_def(L, 1)) {
|
||||||
switch (def->iconType) {
|
switch (def->iconType) {
|
||||||
case ItemIconType::NONE:
|
case ItemIconType::NONE:
|
||||||
@ -47,18 +47,26 @@ static int l_item_get_icon(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_item_caption(lua::State* L) {
|
static int l_caption(lua::State* L) {
|
||||||
if (auto def = get_item_def(L, 1)) {
|
if (auto def = get_item_def(L, 1)) {
|
||||||
return lua::pushstring(L, def->caption);
|
return lua::pushstring(L, def->caption);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_placing_block(lua::State* L) {
|
||||||
|
if (auto def = get_item_def(L, 1)) {
|
||||||
|
return lua::pushinteger(L, def->rt.placingBlock);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg itemlib[] = {
|
const luaL_Reg itemlib[] = {
|
||||||
{"index", lua::wrap<l_item_index>},
|
{"index", lua::wrap<l_index>},
|
||||||
{"name", lua::wrap<l_item_name>},
|
{"name", lua::wrap<l_name>},
|
||||||
{"stack_size", lua::wrap<l_item_stack_size>},
|
{"stack_size", lua::wrap<l_stack_size>},
|
||||||
{"defs_count", lua::wrap<l_item_defs_count>},
|
{"defs_count", lua::wrap<l_defs_count>},
|
||||||
{"icon", lua::wrap<l_item_get_icon>},
|
{"icon", lua::wrap<l_get_icon>},
|
||||||
{"caption", lua::wrap<l_item_caption>},
|
{"caption", lua::wrap<l_caption>},
|
||||||
|
{"get_placing_block", lua::wrap<l_get_placing_block>},
|
||||||
{NULL, NULL}};
|
{NULL, NULL}};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user