Mod requirement warnings not triggering for disabled mods

Discuss modding questions and implementation details.
Post Reply
User avatar
Ralzar
Posts: 1965
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Mod requirement warnings not triggering for disabled mods

Post by Ralzar »

Say you have two mods: Mod1 and Mod2.

Mod2 has a requirement that Mod1 must be present.

If you have both mods in your mod list but deactivate Mod1, when you click Save&Exit, there is no warning from Mod2 that you do not have the required Mod1. As long as it is present in the mod list, it is all fine. Except when you load the game of course, and Mod2 produces errors because its required companion mod has not been loaded in.
My released mods

"I feel like Ralzar specifically wrote those mods for me and then said "Use them". Just so he could watch me die more."
-FuzzyBeanPlays

User avatar
pango
Posts: 3048
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Mod requirement warnings not triggering for disabled mods

Post by pango »

Adding extra warnings seems easy to fix:

Code: Select all

diff --git a/Assets/Game/Addons/ModSupport/ModManager.cs b/Assets/Game/Addons/ModSupport/ModManager.cs
index 5ba88dff9..0a15add81 100644
--- a/Assets/Game/Addons/ModSupport/ModManager.cs
+++ b/Assets/Game/Addons/ModSupport/ModManager.cs
@@ -1051,6 +1051,12 @@ namespace DaggerfallWorkshop.Game.Utility.ModSupport
                         continue;
                     }
 
+                    if (!target.Enabled)
+                    {
+                        errorMessages.Add(string.Format(GetText("dependencyNotEnabled"), dependency.Name));
+                        continue;
+                    }
+
                     // Check load order priority
                     if (!dependency.IsPeer && mod.LoadPriority < target.LoadPriority)
                     {
diff --git a/Assets/StreamingAssets/Text/ModSystem.txt b/Assets/StreamingAssets/Text/ModSystem.txt
index 6e33346c9..bf8b455b5 100644
--- a/Assets/StreamingAssets/Text/ModSystem.txt
+++ b/Assets/StreamingAssets/Text/ModSystem.txt
@@ -63,6 +63,7 @@ titleOrDescriptionMissing,  Title and Description are mandatory fields.
 
 dependencyErrorMessage,                 One or more mods might not work correctly:
 dependencyIsMissing,                    Failed to retrieve mod {0}
+dependencyNotEnabled,                   Mod dependency {0} is not enabled
 dependencyWithIncorrectPosition,        {0} must be positioned above in the load order
 dependencyWithIncompatibleVersion,      {0} has version {1} but {2} or higher is requested
 sortModsQuestion,                       Do you want to sort mods automatically?
I don't know if we want anything more fancy, like propose to enable all needed dependencies (possibly recursively), that could quickly add substantial complexity...
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Ralzar
Posts: 1965
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Mod requirement warnings not triggering for disabled mods

Post by Ralzar »

This has worked fine, but I just discovered one glitch:

If you code your mod with a dependency like this:

Code: Select all

        {
            "Name": "ironman options",
            "IsOptional": true,
            "IsPeer": false,
            "Version": "1.1.2"
        }
And you disable the mod (in this case Ironman Options) you will get the warning.
moddep.PNG
moddep.PNG (61.71 KiB) Viewed 418 times
I would assume this warning should only trigger if IsOptional: false
My released mods

"I feel like Ralzar specifically wrote those mods for me and then said "Use them". Just so he could watch me die more."
-FuzzyBeanPlays

Post Reply