I recall once when I installed a mod and tried to launch Factorio I got an error from that mod during startup (the data*.lua phases) from that mod along the lines of "I noticed you have this other incompatible mod installed; you shouldn't use us both at the same time".
That was very helpful. Now I find myself wanting to do the same with a mod of my own -- that is, provide a useful error message when I detect a fatal configuration issue during startup, and thus pre-empt a load failure with a less useful error that would otherwise occur.
Unfortunately I can't remember in which mod I originally saw this feature, and I can't find anything that would achieve this in the documentation (it's entirely possible I just missed it). Can anyone suggest how to do it?
Providing a useful message for startup errors
-
- Long Handed Inserter
- Posts: 79
- Joined: Sat May 06, 2017 11:25 am
- Contact:
Re: Providing a useful message for startup errors
Just adding to info.json
- negative version is not exists, incompatible.
Code: Select all
"dependencies": [
"base >= 0.15.0",
" ? mod_name < 0.0.0"
-
- Long Handed Inserter
- Posts: 79
- Joined: Sat May 06, 2017 11:25 am
- Contact:
Re: Providing a useful message for startup errors
Thanks, but the mod incompatibility was just an example. My situation is more complex than that; I need to be able to run arbitrary code in data*.lua and report an error if I detect a problem.
Re: Providing a useful message for startup errors
In data*.lua you can call error("there seems to be a problem")
-
- Long Handed Inserter
- Posts: 79
- Joined: Sat May 06, 2017 11:25 am
- Contact:
Re: Providing a useful message for startup errors
Perfect! Thanks .posila wrote:In data*.lua you can call error("there seems to be a problem")
Re: Providing a useful message for startup errors
0.16 also adds incompatible dependencies so in 0.16 you can do this:
and it will trigger your mod to simply be disabled at startup until the given mod is either removed or disabled.
Code: Select all
"dependencies": [
"base >= 0.15.0",
"! mod_name"]
If you want to get ahold of me I'm almost always on Discord.