Page 1 of 1

Log Something When Mod is Missing Dependency

Posted: Wed Sep 15, 2021 4:55 am
by DedlySpyder
Currently, if a mod is added manually without it's dependencies it will be added to the mod-list.json and enabled, but will silently not run in Factorio.

Can a log message be added to describe that this is happening? Why it is happening would be preferable, but at least that it was skipped on purpose would be better than nothing.

Re: Log Something When Mod is Missing Dependency

Posted: Thu Sep 16, 2021 3:21 am
by ssilk
This turning off happens in the loading phase of Factorio, long before the game starts and can be easily seen in the mods-manager. When the game starts it doesn’t know, that there are mods turned off because of missing dependencies.

I tend to move this to not implement.

Re: Log Something When Mod is Missing Dependency

Posted: Thu Sep 16, 2021 3:48 am
by DedlySpyder
ssilk wrote:
Thu Sep 16, 2021 3:21 am
can be easily seen in the mods-manager
This is true, but I have been working with some tooling that runs Factorio through a script, so this isn't possible.

I'm also not sure what you mean by loading phase? Before data/settings, sure, but you mean that the factorio-current.log isn't even being written to until after the mods are determined? I do see log messages from the ModManager about duplicate mods at least.

Re: Log Something When Mod is Missing Dependency

Posted: Thu Sep 16, 2021 6:20 am
by ssilk
Exactly that phase. Ah, and with log-message you mean something in the log-file, not something logged out on screen in the game. I misunderstood that.

From the game logic it must be one of the first things, that needs to be decided, because it can be done in the same process that decides the load-order of the mods. And if there is nothing yet, then, yes, it’s a good idea to add it. Maybe - not tested - you can see that, because a log-entry is missing?

Re: Log Something When Mod is Missing Dependency

Posted: Thu Sep 16, 2021 11:33 pm
by DedlySpyder
It seems there is at least notes that the there are duplicate mods, which I believe would have to be right before dependency resolution (you can't figure out dependencies before you figure out the valid mods). Then it will load the mods in the various stages and say how long they took to load.

Code: Select all

   0.852 Info ModManager.cpp:254: Found duplicate mod Rotatable_Equipment, using higher version (0.0.7 > 0.0.6).
   0.852 Info ModManager.cpp:254: Found duplicate mod Rotatable_Equipment, using higher version (0.1.0 > 0.0.7).
[Loading mods]
   1.659 Verbose ModManager.cpp:565: Time to load mods: 1.07408

Re: Log Something When Mod is Missing Dependency

Posted: Fri Sep 17, 2021 2:39 am
by ssilk
Hm, and how would it be to check the dependencies yourself? I remember I wrote such a parser in lua for v0.13 or so. Wasn’t complicated.
Read the directories, read mod.json, filter out duplicates, store the mods in a list, read dependencies in mod.json and write it into hash (mod -> dependencies) and look, if after load all dependencies have a mod loaded. If not, this mod isn’t activated. It was really not more than a screen of code.

Re: Log Something When Mod is Missing Dependency

Posted: Fri Sep 17, 2021 3:19 am
by DedlySpyder
I suppose I could, but I assume there are plenty of edge cases that would complicate the matter. For example, dependencies can specify the version as well.

If I were to do this myself, I would probably do it with a debug.sethook in lua (since I'm working with an instrument mod). But that's super niche.

Re: Log Something When Mod is Missing Dependency

Posted: Fri Sep 17, 2021 12:23 pm
by eradicator
+1
ssilk wrote:
Fri Sep 17, 2021 2:39 am
Read the directories, read mod.json, filter out duplicates, store the mods in a list, read dependencies in mod.json and write it into hash (mod -> dependencies) and look, if after load all dependencies have a mod loaded. If not, this mod isn’t activated. It was really not more than a screen of code.
You just need two lists though. One from mod-list.json with the should-be-active mods, and one from parsing stdout that contains the mods actually loaded. Dependencies are handled by the game and don't need to be reimplemented.

But that aside it's still reinventing half a wheel. The game already has to do all the checks, and it seems plausible that there actually exists a place in the code where a single log() call could be added to output the result of that check. Which would benefit everyone instead of just a handful of ppl who bother to write a personal script for it. So +1. But personally I'd move it to interface requests.

Re: Log Something When Mod is Missing Dependency

Posted: Sat Sep 18, 2021 4:41 am
by ssilk
Yeah, indeed, it’s an interface request. Moving from suggestions.