libitem: exposed placing_block and emission to lua

This commit is contained in:
REDxEYE 2024-10-29 18:52:31 +03:00
parent aaa2115cd6
commit 76fc7b5fb4
3 changed files with 23 additions and 0 deletions

View File

@ -24,4 +24,7 @@ item.placing_block(itemid: int) -> int
-- Returns the value of the `model-name` property
item.model_name(itemid: int) -> str
-- Returns item emission property value
item.emission(itemid: int) -> str
```

View File

@ -24,6 +24,9 @@ item.placing_block(itemid: int) -> int
-- Возвращает значение свойства `model-name`
item.model_name(itemid: int) -> str
-- Возвращает emission параметр у предмета
item.emission(itemid: int) -> str
```

View File

@ -68,6 +68,22 @@ static int l_model_name(lua::State* L) {
return 0;
}
static int l_emission(lua::State* L) {
if (auto def = get_item_def(L, 1)) {
lua::createtable(L, 4, 0);
lua::pushinteger(L, def->emission[0]);
lua::rawseti(L, 1);
lua::pushinteger(L, def->emission[1]);
lua::rawseti(L, 2);
lua::pushinteger(L, def->emission[2]);
lua::rawseti(L, 3);
lua::pushinteger(L, def->emission[3]);
lua::rawseti(L, 4);
return 1;
}
return 0;
}
const luaL_Reg itemlib[] = {
{"index", lua::wrap<l_index>},
{"name", lua::wrap<l_name>},
@ -77,4 +93,5 @@ const luaL_Reg itemlib[] = {
{"caption", lua::wrap<l_caption>},
{"placing_block", lua::wrap<l_placing_block>},
{"model_name", lua::wrap<l_model_name>},
{"emission", lua::wrap<l_emission>},
{NULL, NULL}};