I want to modify the content of function in another mod in my mod. Is there any way?

Place to get help with not working mods / modding interface.
Post Reply
sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

I want to modify the content of function in another mod in my mod. Is there any way?

Post by sdgmlj »

His function is called by "control.lua". I only make small changes to apply to my mod, not destructive changes, and will not affect his mod. Is there any way?

sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: I want to modify the content of function in another mod in my mod. Is there any way?

Post by sdgmlj »

To put it simply, I want to modify the content of function in another mod. For example, the name is ABCDE (). Is there any way to modify it in my mod?

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: I want to modify the content of function in another mod in my mod. Is there any way?

Post by FuryoftheStars »

I think each mod’s control.lua is running in its own instance, so no, but I’m not 100% on that.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

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

Re: I want to modify the content of function in another mod in my mod. Is there any way?

Post by Pi-C »

sdgmlj wrote:
Sun Jun 05, 2022 11:44 am
To put it simply, I want to modify the content of function in another mod. For example, the name is ABCDE (). Is there any way to modify it in my mod?
Overwriting another mod's function? I hope there's no way you can do that! Could you imagine what kind of nightmare it would be to debug a crash in your mod if somebody else changed one of your functions -- and you can't find anything wrong because your own code is correct, but the overwritten function isn't?

What you should do is to contact the author of the other mod and ask for some compatibility code, e.g. modifying the function if they detect that your mod is running.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: I want to modify the content of function in another mod in my mod. Is there any way?

Post by FuryoftheStars »

Pi-C wrote:
Sun Jun 05, 2022 5:00 pm
Overwriting another mod's function? I hope there's no way you can do that! Could you imagine what kind of nightmare it would be to debug a crash in your mod if somebody else changed one of your functions -- and you can't find anything wrong because your own code is correct, but the overwritten function isn't?
In the games where I’ve modded where this was possible, it wasn’t that bad. Typically the mods that did the overwriting or hooking of the other mod’s functions openly declared that they were, so if there was a problem, it was fairly easy to identify the offender. And at least in the case of an error, the game still knew which mod that code came from so could point you to the correct one.

It was also something of a God send, too, because then you could introduce mod compatibility between your mod and another, without having to wait (potentially) weeks or months for the other modder to do this, assuming they were even still around at all. (I’ve got a mod right now where I think I need to contact 3-4 different mod authors to have them change some code, otherwise my mod won’t work along side theirs.) It also prevents the other modder from needing to include compatibility in their mod for yours, and that person’s, and some other’s, etc, etc.

Personally, the benefits have always outweighed the troubles. But that’s not something I ever see this game doing. Aside from the fact that it would require some major reworking on the devs’ end, it’d probably break every mod in existence right now.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: I want to modify the content of function in another mod in my mod. Is there any way?

Post by ptx0 »

FuryoftheStars wrote:
Sun Jun 05, 2022 5:56 pm
Pi-C wrote:
Sun Jun 05, 2022 5:00 pm
Overwriting another mod's function? I hope there's no way you can do that! Could you imagine what kind of nightmare it would be to debug a crash in your mod if somebody else changed one of your functions -- and you can't find anything wrong because your own code is correct, but the overwritten function isn't?
In the games where I’ve modded where this was possible, it wasn’t that bad. Typically the mods that did the overwriting or hooking of the other mod’s functions openly declared that they were, so if there was a problem, it was fairly easy to identify the offender. And at least in the case of an error, the game still knew which mod that code came from so could point you to the correct one.

It was also something of a God send, too, because then you could introduce mod compatibility between your mod and another, without having to wait (potentially) weeks or months for the other modder to do this, assuming they were even still around at all. (I’ve got a mod right now where I think I need to contact 3-4 different mod authors to have them change some code, otherwise my mod won’t work along side theirs.) It also prevents the other modder from needing to include compatibility in their mod for yours, and that person’s, and some other’s, etc, etc.

Personally, the benefits have always outweighed the troubles. But that’s not something I ever see this game doing. Aside from the fact that it would require some major reworking on the devs’ end, it’d probably break every mod in existence right now.
yeah, this is why Barotrauma mods are really fun to develop. also, they give you complete source access to the game.

Post Reply

Return to “Modding help”