Update config file after pruning at startup

This commit is contained in:
Jordan Irwin 2021-08-27 17:30:11 -07:00
parent fc20b379f9
commit d35d7086a4
2 changed files with 13 additions and 2 deletions

11
api.lua
View File

@ -571,7 +571,10 @@ end
--- Prunes unknown items & updates aliases in shops.
--
-- @function server_shop.prune_shops
ss.prune_shops = function()
-- @tparam[opt] bool update_config
ss.prune_shops = function(update_config)
update_config = update_config == true
-- show warning if no currencies are registered
if not ss.currency_is_registered() then
ss.log("warning", "no currencies registered")
@ -623,4 +626,10 @@ ss.prune_shops = function()
ss.register(id, def.products, def.buyer)
end
end
if update_config then
local shops_data = wdata.read("server_shops")
shops_data.shops = shops
wdata.write("server_shops", shops_data)
end
end

View File

@ -44,4 +44,6 @@ end
ss.file_load()
core.register_on_mods_loaded(ss.prune_shops)
core.register_on_mods_loaded(function()
ss.prune_shops(true)
end)