Modding Dependency without Code

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Loup&Snoop
Inserter
Inserter
Posts: 37
Joined: Wed Dec 04, 2024 4:33 am
Contact:

Modding Dependency without Code

Post by Loup&Snoop »

Context
Sometimes, when modding, I would like to depend on X mod to have factorio use that mod’s assets or libraries. However:
1) Some mods are stuck in 1.1
2) Many mods normally come with code that I don’t want executed. Data stage stuff can be reverted (with great effort) while many things can’t be blocked (eg control stage).
Interface Request
Please add a field to info.json where mod A can require mod B's files without running its code and forcing its dependencies (allowing 1.1 mods). When a mod declares this dependency, such as ”mod-B = 69.420.0” in its info.json AND mod-B is disabled, then factorio makes its files accessible, without running code for mod B. For example, mod-A can run require(“__mod-B__.script.library.my-big-library”) or icon = “__mod-B__.graphics.big-black-square.png”

The logic is:
1) If mod B is enabled, then run it like normal.
2) Else, if any mod has a file-dependency on mod-B, make the files available without executing its code (Ignore the dependencies in its info.json. Do not run migrations. Do not run data.lua/control.lua/etc).
3) Else, mod-B basically does not exist.

These “file-only dependencies” should be in a separate array in info.json, so the mod can independently use normal flags demarking dependency information for what happens if mod B IS enabled. eg:
“! mod-B”, … file_dependencies = [“mod-B 420.69.0”] means mod-A is incomaptible with mod B (it CANNOT be enabled), but it does require mod-B’s files be made available. Similarly, mod-A could declare an optional dependency etc on mod-B to affect load order… All the logic in this proposal is independent of normal dependency logic.
The Benefits
1) Easily recycle other mods, including abandoned 1.1 mods.
2) Other mods can be included into bigger mods without the issue of “the graphics must come with the code.”
3) Better use of dependencies => fewer duplicates messing with Wube’s servers.
Last edited by Loup&Snoop on Sun Jul 06, 2025 11:56 pm, edited 2 times in total.
StephenB
Burner Inserter
Burner Inserter
Posts: 15
Joined: Fri Jul 19, 2024 10:12 am
Contact:

Re: Modding Dependency without Code

Post by StephenB »

+1. For example I would like to have this for the Space Age mod. Currently, if I make a mod that uses Space Age graphics but is incompatible with Space Age itself, I can't just include graphics like "__space-age__/graphics/something.png", because it will complain that the Space Age mod is disabled. So instead I have to copy the graphics into my own mod, forcing players to redownload graphics they already have. And to make the mod unusable by people who haven't bought the DLC, I would have to add feature flags for features I'm not even using. I would prefer to be able to use Space Age's graphics without running all of its code.

There was a proposal recently (can't remember by who) that mods should include a hidden startup setting that just disables all the code. That's an alternative solution to this problem that doesn't need an engine change but would require more work from mod creators. You could do something like this in the engine too, like adding a settings-stage global like `skip_mod_code["space-age"] = true` that will just skip running data.lua and control.lua from that mod.
Loup&Snoop
Inserter
Inserter
Posts: 37
Joined: Wed Dec 04, 2024 4:33 am
Contact:

Re: Modding Dependency without Code

Post by Loup&Snoop »

Good point. This is really handy for anything spage-related.

There are many mods that want to use spage assets without relying on spage, which then requires feature flags + duplicating assets.

It would be cleaner to tell factorio: “Please make spage files available for me to draw from, regardless of whether or not spage is enabled.”
Post Reply

Return to “Modding interface requests”