Feature #152 and potential fix #320

- Added Lua scripts hud.open, inventory.create and inventory.remove
- Window now resizes even if it is not focused
This commit is contained in:
opchik98
2024-11-07 18:38:24 +02:00
parent 5faca685ec
commit 8e549fe806
11 changed files with 117 additions and 13 deletions
@@ -109,6 +109,26 @@ static int l_inventory_unbind_block(lua::State* L) {
return 0;
}
static int l_inventory_create(lua::State* L) {
auto invsize = lua::tointeger(L, 1);
auto inv = level->inventories->create(invsize);
if (inv == nullptr) {
return lua::pushinteger(L, 0);
}
return lua::pushinteger(L, inv->getId());
}
static int l_inventory_remove(lua::State* L) {
auto invid = lua::tointeger(L, 1);
auto inv = get_inventory(invid);
if (inv == nullptr) {
return 0;
}
level->inventories->remove(invid);
return 0;
}
static int l_inventory_clone(lua::State* L) {
auto id = lua::tointeger(L, 1);
auto clone = level->inventories->clone(id);
@@ -145,5 +165,7 @@ const luaL_Reg inventorylib[] = {
{"get_block", lua::wrap<l_inventory_get_block>},
{"bind_block", lua::wrap<l_inventory_bind_block>},
{"unbind_block", lua::wrap<l_inventory_unbind_block>},
{"create", lua::wrap<l_inventory_create>},
{"remove", lua::wrap<l_inventory_remove>},
{"clone", lua::wrap<l_inventory_clone>},
{NULL, NULL}};