core.remove_packs

This commit is contained in:
MihailRis
2024-04-04 03:53:58 +03:00
parent 1c82eeafd2
commit 13ae6c6950
5 changed files with 75 additions and 24 deletions
+16
View File
@@ -57,6 +57,21 @@ static int l_delete_world(lua_State* L) {
return 0;
}
static int l_remove_packs(lua_State* L) {
if (!lua_istable(L, 1)) {
luaL_error(L, "strings array expected as an argument");
}
std::vector<std::string> packs;
int len = lua_objlen(L, 1);
for (int i = 0; i < len; i++) {
lua_rawgeti(L, -1, i+1);
packs.push_back(lua_tostring(L, -1));
lua_pop(L, 1);
}
menus::remove_packs(scripting::engine, scripting::controller, packs);
return 0;
}
static int l_get_bindings(lua_State* L) {
auto& bindings = Events::bindings;
lua_createtable(L, bindings.size(), 0);
@@ -101,6 +116,7 @@ const luaL_Reg corelib [] = {
{"open_world", lua_wrap_errors<l_open_world>},
{"close_world", lua_wrap_errors<l_close_world>},
{"delete_world", lua_wrap_errors<l_delete_world>},
{"remove_packs", lua_wrap_errors<l_remove_packs>},
{"get_bindings", lua_wrap_errors<l_get_bindings>},
{"get_setting", lua_wrap_errors<l_get_setting>},
{"set_setting", lua_wrap_errors<l_set_setting>},