Page 1 of 1

Modifying a mod with another mod

Posted: Mon Dec 30, 2019 5:34 am
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!

Re: Modifying a mod with another mod

Posted: Mon Dec 30, 2019 8:42 am
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.

Re: Modifying a mod with another mod

Posted: Mon Dec 30, 2019 9:33 am
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

Re: Modifying a mod with another mod

Posted: Mon Dec 30, 2019 9:43 am
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).

Re: Modifying a mod with another mod

Posted: Mon Dec 30, 2019 11:08 am
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.

Re: Modifying a mod with another mod

Posted: Mon Dec 30, 2019 11:17 am
by DaveMcW
Dependency is definitely safer. Please save data-final-fixes for mods that actually need it.