add app.reset_content 'non_reset_packs' optional argument

This commit is contained in:
MihailRis
2025-11-09 23:04:50 +03:00
parent 50d520e747
commit 0e6fb878bf
9 changed files with 51 additions and 14 deletions
+22 -1
View File
@@ -742,15 +742,36 @@ function require(path)
return __load_script(prefix .. ":modules/" .. file .. ".lua", nil, env)
end
function __scripts_cleanup()
-- TODO: move to string
local function join(t, sep)
local s = ""
for i, v in ipairs(t) do
s = s..tostring(v)
if i < #t then
s = s..sep
end
end
return s
end
function __scripts_cleanup(non_reset_packs)
debug.log("cleaning scripts cache")
if #non_reset_packs == 0 then
debug.log("no non-reset packs")
else
debug.log("non-reset packs: "..join(non_reset_packs, ", "))
end
for k, v in pairs(__cached_scripts) do
local packname, _ = parse_path(k)
if table.has(non_reset_packs, packname) then
goto continue
end
if packname ~= "core" then
debug.log("unloaded "..k)
__cached_scripts[k] = nil
package.loaded[k] = nil
end
::continue::
end
end