add item.get_model

This commit is contained in:
MihailRis 2024-10-30 12:55:08 +03:00
parent b2e5254037
commit 7c933f89c6
3 changed files with 14 additions and 0 deletions

View File

@ -21,4 +21,7 @@ item.icon(itemid: int) -> str
-- Returns the integer id 'placing-block' or 0
item.get_placing_block(itemid: int) -> int
-- Returns the value of the `model-name` property
item.get_model_name(itemid: int) -> str
```

View File

@ -21,6 +21,9 @@ item.icon(itemid: int) -> str
-- Возвращает числовой id блока, назначенного как 'placing-block' или 0
item.get_placing_block(itemid: int) -> int
-- Возвращает значение свойства `model-name`
item.get_model_name(itemid: int) -> str
```

View File

@ -61,6 +61,13 @@ static int l_get_placing_block(lua::State* L) {
return 0;
}
static int l_get_model_name(lua::State* L) {
if (auto def = get_item_def(L, 1)) {
return lua::pushstring(L, def->modelName);
}
return 0;
}
const luaL_Reg itemlib[] = {
{"index", lua::wrap<l_index>},
{"name", lua::wrap<l_name>},
@ -69,4 +76,5 @@ const luaL_Reg itemlib[] = {
{"icon", lua::wrap<l_get_icon>},
{"caption", lua::wrap<l_caption>},
{"get_placing_block", lua::wrap<l_get_placing_block>},
{"get_model_name", lua::wrap<l_get_model_name>},
{NULL, NULL}};