Question about mod encapsulation.

Place to get help with not working mods / modding interface.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Question about mod encapsulation.

Post by credomane »

Are mods in Factorio isolated from one another? If so how? To what degree?

I see a lot of mods that interact with one another. I'm curious as to how that is done. From what I can tell poking about they check remote.interfaces for the mod then do a remove.call.
Is this the only way mods can see each other? Am I wasting time and effort with my mod making sure everything is prepended with my mod's name to avoid naming conflicts? What about when using the global variable? Is the global variable shared between all mods or is it "unique" to each mod? Such as if one mod does global.a =1 and my mod does global.a=3 later do both mods see global.a as 3 when they check on it in the future or what they each set it too?

If all of this is covered in the wiki please provide me a link to the page with this info. I certainly wasn't locating it. Thanks!
Rseding91
Factorio Staff
Factorio Staff
Posts: 15950
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Question about mod encapsulation.

Post by Rseding91 »

credomane wrote:Am I wasting time and effort with my mod making sure everything is prepended with my mod's name to avoid naming conflicts?
Yes, each mod runs in its own lua instance so everything at the control.lua level is unique and isolated for your mod.

The only shared state is the data.lua loading phase and that happens one by one for mods.
If you want to get ahold of me I'm almost always on Discord.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: Question about mod encapsulation.

Post by credomane »

Thanks Rseding91! I knew during initial mod loading the data was shared between all mods but I didn't know about anything else. Suppose if I thought about it I could have just made two dummy mods that hated each other and the results of that would have given me my answer.

Another question if you don't mind. When you save your game in Factorio what parts of the mod get saved in the world save? Only the things in global, everything or just depends?
Rseding91
Factorio Staff
Factorio Staff
Posts: 15950
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Question about mod encapsulation.

Post by Rseding91 »

credomane wrote:Thanks Rseding91! I knew during initial mod loading the data was shared between all mods but I didn't know about anything else. Suppose if I thought about it I could have just made two dummy mods that hated each other and the results of that would have given me my answer.

Another question if you don't mind. When you save your game in Factorio what parts of the mod get saved in the world save? Only the things in global, everything or just depends?
The only Lua data that's saved is the "global" table for each mod.
If you want to get ahold of me I'm almost always on Discord.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: Question about mod encapsulation.

Post by credomane »

Thanks again! Now back to working on my mod. :D
Post Reply

Return to “Modding help”