Make scenario locale files available for error()

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
asher_sky
Inserter
Inserter
Posts: 44
Joined: Sun Oct 18, 2020 7:13 pm
Contact:

Make scenario locale files available for error()

Post by asher_sky »

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.

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.
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:

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
Would it be possible for scenario LocalisedStrings to be within scope of an error() call from the scenario control file?
Thanks :)

Post Reply

Return to “Modding interface requests”