Page 1 of 1

Allow one mod to "provide" another

Posted: Wed Apr 24, 2019 9:23 pm
by sparr
I would like to be able to put an entry in foomod/info.json that says foomod satisfies dependencies on barmod.

Primary use case is to release two versions of the same mod, one with and one without high resolution graphics, either of which would satisfy dependencies on the mod.

Re: Allow one mod to "provide" another

Posted: Thu Apr 25, 2019 2:44 am
by emptyrivers
If I understand this request right, then I think that the opposite solution would make more sense. So, you could write in one mod's info.json (for example):

Code: Select all

{
	"name":"dependentmod",
	//...
	"dependencies" : [ "foo|bar"], // foo or bar could satisfy this dependency
	//...
}
and then, if at least one of foo or bar were enabled, then dependentmod would be loaded.

Re: Allow one mod to "provide" another

Posted: Thu Apr 25, 2019 7:13 am
by sparr
That would require every dependent mod to know about both foo and bar, which seems like an unnecessary burden if the author of the two mods knows their mods are interchangeable.

Re: Allow one mod to "provide" another

Posted: Thu Apr 25, 2019 7:34 am
by Pi-C
emptyrivers wrote: Thu Apr 25, 2019 2:44 am If I understand this request right, then I think that the opposite solution would make more sense.
I'm using Debian, so I'm familiar with dependencies and packages that "provide" some functionality. Consider this example:

You want to install an MTA (mail transport agent -- a service running in the background that receives mail and passes it on to remote servers or local users). Let's say you settle on postfix as MTA. Postfix "depends" (hard dependency) on several packages and "suggests" (kind of a soft dependency -- you don't have to install any of those, but it would make sense to do it), among others, "mail-reader". This is a purely virtual package -- there is no real package of this name, but there are many that provide this functionality: balsa, evolution, kmail, mutt, thunderbird etc.

Tomorrow, somebody could release another program that can be used to read e-mails. The maintainers of the existing MTAs wouldn't even know it's there, so they couldn't add a dependency on it to their package. However, the author of the new package can call out to them "Hey, this new package does what you require, too!" by adding "Provides: mail-reader" to their package. So, adding "Provides" allows other mods to depend on functionality instead of specific packages -- functionality that can be found in well-known and in anonymous packages.

How could that be relevant to Factorio? Well, suppose you want to spice up combat a bit, so you make a mod package pulling in new enemies and new weapons, specifically sniper stuff . A short search on the mod portal brings up, among others, Rampant, Natural Evolution Enemies, Necromant, 5Dim's mod - Battlefield, Bob's Enemies, and Swarmageddon - Enhanced Biter Swarms for "enemies" and Schall Ammo Turrets, Combat by Samuel, Combat by lamp181, and Sniper rifle for "sniper". It doesn't matter to you which mod is pulled in, so if your users have one of the above mods already installed, they don't need to install another one with similar features. If Rampant et al. could have something like "Provides: new-enemies" and the others something like "Provides: weapon-sniper", you could just include "Dependencies: new-enemies, weapon-sniper" to pull in everything that is required. Requests like "Could you add a dependency on [insert name of new mod here]?" would be a thing of the past, as the relevant mods would announce on their own that they have what your mod package requires.

I therefore believe that Factorio supporting a "Provides:" tag in addition to "Dependencies:" would be a useful feature, indeed. :-)

Re: Allow one mod to "provide" another

Posted: Thu Apr 25, 2019 9:43 am
by bobingabout
My solution...
put both as an optional dependency
then in the mod itself, check to see if the entity exists.
however, optional dependencies don't force a mod to exist, so there's still the possibility that neither will be there.

A this or that would be good here. Other areas of the game could use similar things... like Technology prerequisites. need a roboport? it's unlocked by Logistic Robots and Construction Robots. currently you have to either have both, or neither as a prerequisite. I'm thinking of other areas in my own mods personally, like... you need Oxygen? you can get that either from Nitrogen processing or Electrolysis. Sulphur Dioxide? you can get that from Oil processing or Lead processing as a byproduct from smelting Lead the chemical way.

Recipes too... Like, Charcoal or Coal... Synthetic wood or Wood... currently you basically need a different recipe for each variation.