Make scenario locale files available for error()
Posted: Fri Sep 01, 2023 8:27 am
I'm working on a mod that adds a scenario. The mod makes some data stage changes that are required for the scenario. Because the scenario can be saved and then easily or accidentally loaded without the mod enabled, I want to add a localised error message if the mod is not enabled.
However with this example setup if you start the scenario, save the map, disable the mod, and load the map again, the error message reads:
Would it be possible for scenario LocalisedStrings to be within scope of an error() call from the scenario control file?
Thanks
Code: Select all
-- example_mod/scenarios/example/control.lua
if not script.active_mods["example_mod"] then
error({"error_locale.mod_required"})
end
-- example_mod/scenarios/example/locale/en/locale.cfg
[error_locale]
mod_required=Please enable the mod to load the scenario.
Code: Select all
Unknown key: "error_locale.mod_required"
stack traceback:
[C]: in function 'error'
...tion Support/factorio/temp/currently-playing/control.lua:2: in main chunk
Thanks
