Air Filtering Advanced


Add machines that use craftable and refurbishable filters (and electricity) to clear pollution

4 years ago
0.14 - 0.18
78

i modify config-setting handling to prevent crashes

6 years ago
(updated 6 years ago)

So in the descriptions for the startup-config settings you do state not to use the different settings when specific mods are not installed, but instead: use an AND condition wherever these settings are relevant.
Such as:


if mods["mod's internal name here"] and settings.startup["setting name"].value = true then {do stuff}

6 years ago

In that way, even if a player sets a config to use bob's electronics, then disables a bunch of mods but forgets AFA is set to require it in the startup-config settings, it won't crash on load, but instead ignore whatever adjustments it would make when bob's electronics IS enabled, and proceed without erroring

6 years ago

that way, if either: a) the mod is not enabled, or b) the setting is not enabled, the code doesn't run, even if one of them is true. what you want is for when BOTH are true, make the recipe modifications.

6 years ago

when i was testing it my game didn't load with the setting enabled and the mod disabled, so when i got it to work i wen't "if it ain't broke don't fix it"

6 years ago

the config setting should only take affect IFF (if and only if) the mod is enabled. for some reasons, a user may need to disable or choose not to play with Mod-B, if your config setting explicitly demands that mod-B is enabled, any changes to it or disabling of it will cause your mod to crash, and will not be able to be loaded until Mod-B is fixed. Thus, the proper way to handle it is to use an AND statement or a nested-IF statement that checks if the mod is enabled, and if that mod exists, than check if the setting is enabled---then, and only then---make those changes. if the setting is on, but the mod isn't enabled, the code should never even reach that part where changes are being made (under the assumption) that the mod is enabled. get me?

6 years ago

to clarify:
change recipe-updates.lua to use


if mods["bobplates"] and settings.startup["af-integrate-bobs-plates"].value == true then
---do stuff for bob's plates.
end
-------------------------
the order is important, and the and is also. the config should only matter IF bob's plates is also included.

6 years ago

similar changes for:
if mods["bobelectronics"] and settings.startup["af-integrate-bobs-electronics"].value == true then
-----do stuff for bob's electronics
end

New response