Log Something When Mod is Missing Dependency

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Log Something When Mod is Missing Dependency

Post 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.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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?
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Log Something When Mod is Missing Dependency

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Log Something When Mod is Missing Dependency

Post by ssilk »

Yeah, indeed, it’s an interface request. Moving from suggestions.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Post Reply

Return to “Modding interface requests”