Page 1 of 1

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

Posted: Wed Jul 21, 2021 7:46 pm
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"}

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

Posted: Wed Jul 21, 2021 10:09 pm
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.

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

Posted: Thu Jul 22, 2021 1:45 am
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

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

Posted: Thu Jul 22, 2021 1:55 am
by DaveMcW
You can't edit a local variable in another mod.

The only option is to undo whatever it did.

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

Posted: Thu Jul 22, 2021 2:02 am
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.

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

Posted: Thu Jul 22, 2021 4:01 am
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.

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

Posted: Thu Jul 22, 2021 4:59 am
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