How do you edit other mod lists/arrays from within your own mod

Place to get help with not working mods / modding interface.
Post Reply
Scully_Dog
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Feb 01, 2018 1:45 am
Contact:

How do you edit other mod lists/arrays from within your own mod

Post by Scully_Dog »

I created a mod that adds more labs. I added integration for bob's module lab but now it interferes with the 30 more science pack mod. I know the simple fix is to change the MSP files directly but I was wondering if I could fix it in my mod alone.

This is the MSP list I need to append.

local blacklistLabs ={"creative-mode-fix_creative-lab", "lab-module"}

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

Re: How do you edit other mod lists/arrays from within your own mod

Post by DaveMcW »

You set the mod as a (optional) dependency, then clean up everything it did that you don't like.

Since the MSP blacklist is in data-updates.lua, you should also put your fix in data-updates.lua.

Scully_Dog
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Feb 01, 2018 1:45 am
Contact:

Re: How do you edit other mod lists/arrays from within your own mod

Post by Scully_Dog »

Here is my mod.

https://mods.factorio.com/mod/morelabs

How do I edit their list cause it is local and I can not seem to edit it, closest I think I got it to was this.

Code: Select all

if not morescience.blacklistLabs then morescience.blacklistLabs = {} end

if settings.startup["morelabs-modlabs"].value == true and settings.startup["morelabs-msp"].value == true then
    morescience.blacklistLabs = {"creative-mode-fix_creative-lab", "lab-module", "lab-mod-mk2", "lab-mod-mk3", "lab-mod-mk4", "lab-mod-mk5", "lab-bigmod-mk1", "lab-bigmod-mk2", "lab-bigmod-mk3", "lab-bigmod-mk4", "lab-bigmod-mk5"}
end

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

Re: How do you edit other mod lists/arrays from within your own mod

Post by DaveMcW »

You can't edit a local variable in another mod.

The only option is to undo whatever it did.

Scully_Dog
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Feb 01, 2018 1:45 am
Contact:

Re: How do you edit other mod lists/arrays from within your own mod

Post by Scully_Dog »

So there is NO way for me to make my new labs not have the new sciences added without changing MSP. I think im going to contact the MSP creator and see if they could add that for me and other coders could have that useful function.

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

Re: How do you edit other mod lists/arrays from within your own mod

Post by DaveMcW »

Here is an example of how to undo another mod's changes to data.raw:

Code: Select all

local base_inputs = {
  "automation-science-pack",
  "logistic-science-pack",
  "military-science-pack",
  "chemical-science-pack",
  "production-science-pack",
  "utility-science-pack",
  "space-science-pack",
}
data.raw.lab["lab-mk2"].inputs = base_inputs
data.raw.lab["lab-mk3"].inputs = base_inputs
data.raw.lab["lab-mk4"].inputs = base_inputs
data.raw.lab["lab-mk5"].inputs = base_inputs
You must put this in data-updates.lua.

Scully_Dog
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Feb 01, 2018 1:45 am
Contact:

Re: How do you edit other mod lists/arrays from within your own mod

Post by Scully_Dog »

Thank you, I will be implimenting this code with the needed changes and updating my mod then, Thanks.

Edit - Works completely now thanks, if you have any suggestions of anything I should add I would love to hear them

Post Reply

Return to “Modding help”