Modifying a mod with another mod

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Brathahn
Fast Inserter
Fast Inserter
Posts: 108
Joined: Sat Aug 02, 2014 1:50 pm
Contact:

Modifying a mod with another mod

Post by Brathahn »

Hi,
is it possible to remove/change funcions or recipes from mods with another mod?
If yes, are there examples of it or how this would be done?

lets say i have downloaded mod-A from the mod portal but i dont like certain functions or recipes added by that mod.
so my usual action would be: unzip the mod and change it directly and be happy about it.

when i want to do this in multiplayer this would not be practical because i would have to send everyone the modded files or redistribute the mod on my own.. wich may lead to drama and dispute over copyright stuff.
so i thougt of mod-B that would change mod-A without any problems. since i dont change or redistribute mod-A there would be no copyright drama.

Thanks in advance!

Pi-C
Smart Inserter
Smart Inserter
Posts: 1645
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Modifying a mod with another mod

Post by Pi-C »

Brathahn wrote:
Mon Dec 30, 2019 5:34 am
so i thougt of mod-B that would change mod-A without any problems. since i dont change or redistribute mod-A there would be no copyright drama.
I did this with Combat by Samuel + minus. It's a mod that just adds options to modify attributes set by another mod. The important thing is, you need to make sure that the other mod is loaded before yours, so it doesn't revert your changes. You can achieve this by adding a dependency in info.json. I did it this way:

Code: Select all

  "dependencies": ["base >= 0.17.0", "Combat_by_Samuel >= 1.1.1"]
By the way, here's the syntax for dependencies (according to an error message found in the log file):

Code: Select all

"[?|(?)|!] ModName [ModVersion specifier]"
  • "? ModName" marks an optional dependency: If ModName is active, it will be loaded before your mod.
  • "(?) ModName" marks a hidden optional dependency: It's just the same as a normal optional dependency, but won't be listed by the game's mods manager.
  • "! ModName" marks a conflict: Only one of the mods can be active.
ModVersion specifier is an operator (for example "=" or ">") plus the version number.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: Modifying a mod with another mod

Post by PyroFire »

Brathahn wrote:
Mon Dec 30, 2019 5:34 am
is it possible to remove/change funcions or recipes from mods with another mod?
It is not possible to change or remove functions in another mod.

It is very easy to change recipes that were registered by another mod by simply ensuring your code runs after the data you need to modify is registered.
This can be done by depending on that mod (so it loads first), or by using the next data stage (e.g. if the mod uses data-updates, i can put my changes in data-final-fixes).

During the control stage you cannot interact with other mods without the use of remotes.
https://lua-api.factorio.com/latest/LuaRemote.html

Pi-C
Smart Inserter
Smart Inserter
Posts: 1645
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Modifying a mod with another mod

Post by Pi-C »

PyroFire wrote:
Mon Dec 30, 2019 9:33 am
Brathahn wrote:
Mon Dec 30, 2019 5:34 am
is it possible to remove/change funcions or recipes from mods with another mod?
It is not possible to change or remove functions in another mod.
Ooops, didn't notice the functions part when I replied previously … :-D
It is very easy to change recipes that were registered by another mod by simply ensuring your code runs after the data you need to modify is registered.
This can be done by depending on that mod (so it loads first), or by using the next data stage (e.g. if the mod uses data-updates, i can put my changes in data-final-fixes).
Wouldn't a dependency be safer? Using the next data stage wouldn't work if the other mod changed something there as well. Also, what works today (e.g. the other mod only acts in data.lua, yours in data-updates.lua) could break tomorrow (if the other mod is changed to act in, say, data-final-fixes.lua).
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: Modifying a mod with another mod

Post by PyroFire »

Pi-C wrote:
Mon Dec 30, 2019 9:43 am
Wouldn't a dependency be safer?
It depends on what you're doing.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Modifying a mod with another mod

Post by DaveMcW »

Dependency is definitely safer. Please save data-final-fixes for mods that actually need it.

Post Reply

Return to “Modding help”