I want to modify the content of function in another mod in my mod. Is there any way?
I want to modify the content of function in another mod in my mod. Is there any way?
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?
Re: I want to modify the content of function in another mod in my mod. Is there any way?
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?
-
- Smart Inserter
- Posts: 2534
- 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?
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
Re: I want to modify the content of function in another mod in my mod. Is there any way?
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!
-
- Smart Inserter
- Posts: 2534
- 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?
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.Pi-C wrote: ↑Sun Jun 05, 2022 5:00 pmOverwriting 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?
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
Re: I want to modify the content of function in another mod in my mod. Is there any way?
yeah, this is why Barotrauma mods are really fun to develop. also, they give you complete source access to the game.FuryoftheStars wrote: ↑Sun Jun 05, 2022 5:56 pmIn 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.Pi-C wrote: ↑Sun Jun 05, 2022 5:00 pmOverwriting 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?
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.