Because the ore tables and stuff are local and not stored in global, they don't persist after saving and loading. (the source of the code was a server, which never saved/loaded and unfortunately wrote their code without caring about init, config change, and loading)
core/config/config.lua will be the source of many bugs or just bad behaviors, because the config table only gets changed on init.
To fix it for new players, you can assign it to global.config or w/e and then use that wherever you need it, instead of using the config from a require at the top. Keep the require in map_helper for init/config_change, then remove ALL of the other requires, it is not the right thing to do unless you edit the config on load and never use it outside events. Also, you can do local config = global.config
inside functions instead of replacing each specific use of config
in a function.
For existing players, it will need to be initialized if it doesn't exist on_configuration_changed.
on_load can be ignored because if you increment the mod version, on_config will raise
at the start of config.on_init, global.config = config
. config can get an on_configuration_changed which runs if not global.config then config.init() end
Must be added in
At least these files effected:
market.lua
rocks_yield_enemies.lua
rocks_yield_loot.lua
rocks_yield_ore.lua
trees_yield_ore.lua
cell_helper.lua
filler_helper.lua
loot_helper.lua
map_helper.lua
map_functions.lua
utils.lua
all the variant N*Ns
dungeon.lua
A small mention, having config in global will remove the functions on the first save after and put a warning "21674.762 Info LuaValueSaver.cpp:169: WorldMiner: removed 3 lua functions when saving" . It won't cause an error in modhelper.lua because modhelper having require uses the original table for on_init and on_configuration_changed, but on_chunk_generated would need to use the global.config.
It's not a lot of rewriting or time, it's just annoying. I could do an issue report on github and link files/changes there if you want, to compare how I have mine.