mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add app.reset_content 'non_reset_packs' optional argument
This commit is contained in:
parent
50d520e747
commit
0e6fb878bf
9 changed files with 51 additions and 14 deletions
|
|
@ -348,10 +348,13 @@ void scripting::on_world_quit() {
|
|||
scripting::controller = nullptr;
|
||||
}
|
||||
|
||||
void scripting::cleanup() {
|
||||
void scripting::cleanup(const std::vector<std::string>& nonReset) {
|
||||
auto L = lua::get_main_state();
|
||||
lua::requireglobal(L, "pack");
|
||||
for (auto& pack : content_control->getAllContentPacks()) {
|
||||
if (std::find(nonReset.begin(), nonReset.end(), pack.id) != nonReset.end()) {
|
||||
continue;
|
||||
}
|
||||
lua::requirefield(L, "unload");
|
||||
lua::pushstring(L, pack.id);
|
||||
lua::call_nothrow(L, 1);
|
||||
|
|
@ -359,7 +362,12 @@ void scripting::cleanup() {
|
|||
lua::pop(L);
|
||||
|
||||
if (lua::getglobal(L, "__scripts_cleanup")) {
|
||||
lua::call_nothrow(L, 0);
|
||||
lua::createtable(L, nonReset.size(), 0);
|
||||
for (size_t i = 0; i < nonReset.size(); i++) {
|
||||
lua::pushstring(L, nonReset[i]);
|
||||
lua::rawseti(L, i + 1);
|
||||
}
|
||||
lua::call_nothrow(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue