Page 1 of 1

A way to edit productivity module limitations

Posted: Sat Jan 13, 2024 3:04 pm
by DiegoPro77
Hi guys, let me go straight into this.

I'm not good at Lua probably, but I need to add some recipes ("iron-dust0", "iron-dust1", "iron-dust2") to the productivity module limitations and dunno how to do that.

I saw that it is the function that defines to which recipes productivity modules can be applied:

Code: Select all

function productivity_module_limitation()
return
      {
        "sulfuric-acid",
        "basic-oil-processing",
        "advanced-oil-processing",
        "coal-liquefaction",
        "heavy-oil-cracking",
        "light-oil-cracking",
        "solid-fuel-from-light-oil",
        "solid-fuel-from-heavy-oil",
        "solid-fuel-from-petroleum-gas",
        "lubricant",
        "iron-plate",
        "copper-plate",
        "steel-plate",
        "stone-brick",
        "sulfur",
        "plastic-bar",
        "empty-barrel",
        "uranium-processing",
        "copper-cable",
        "iron-stick",
        "iron-gear-wheel",
        "electronic-circuit",
        "advanced-circuit",
        "processing-unit",
        "engine-unit",
        "electric-engine-unit",
        "uranium-fuel-cell",
        "explosives",
        "battery",
        "flying-robot-frame",
        "low-density-structure",
        "rocket-fuel",
        "nuclear-fuel",
        "nuclear-fuel-reprocessing",
        "rocket-control-unit",
        "rocket-part",
        "automation-science-pack",
        "logistic-science-pack",
        "chemical-science-pack",
        "military-science-pack",
        "production-science-pack",
        "utility-science-pack",
        "kovarex-enrichment-process"
      }
end
And, moreover, should I edit this thing or can I add more functions like this to the data.raw limitations of the productivity modules?

Re: A way to edit productivity module limitations

Posted: Sat Jan 13, 2024 6:36 pm
by Qon
First step is to read the modding tutorial and then the second step is to familiarize yourself with how to navigate the documentation.
DiegoPro77 wrote: Sat Jan 13, 2024 3:04 pm And, moreover, should I edit this thing or can I add more functions like this to the data.raw limitations of the productivity modules?
Wrong question.
You can't edit the base game files. Well, you can, but you will break the game in various ways.
Make a mod.
If you make a function or not isn't the question, the question is: where is it called? It just returns a list, what happens to that list? You need to understand where and how it is used. The function itself is pointless, it doesn't do anything.

Re: A way to edit productivity module limitations

Posted: Sat Jan 13, 2024 6:43 pm
by DaveMcW
In your mod's data.lua write:

Code: Select all

for _, module in pairs(data.raw.module) do
  if module.effect.productivity and module.limitation then
    table.insert(module.limitation, "iron-dust0")
    table.insert(module.limitation, "iron-dust1")
    table.insert(module.limitation, "iron-dust2")
  end
end

Re: A way to edit productivity module limitations

Posted: Mon Apr 01, 2024 8:38 am
by DiegoPro77
Sorry for the late reply.
Qon wrote: Sat Jan 13, 2024 6:36 pm First step is to read the modding tutorial and then the second step is to familiarize yourself with how to navigate the documentation.
I don't really understand how functions, events and other things can be made - and I think it is more a "my" problem since I don't understand Lua and coding so deeply. Maybe an high school informatics course wasn't enough sorry. :lol:
Qon wrote: Sat Jan 13, 2024 6:36 pm Wrong question.
You can't edit the base game files. Well, you can, but you will break the game in various ways.
Make a mod.
Yeah I was modding indeed - I'd never edit factorio files directly to then have to reinstall everything. xD
Qon wrote: Sat Jan 13, 2024 6:36 pm If you make a function or not isn't the question, the question is: where is it called? It just returns a list, what happens to that list? You need to understand where and how it is used. The function itself is pointless, it doesn't do anything.
Yeah probably. Should have done that. But I felt a bit overwhelmed if you know what I mean and thought that writing here would have helped me more than trying by myself. Next time I'll try to tryhard a little more. :lol:

The thing is that - as long as I've to read other's files and functions (even good modders that code properly), comments sometimes help, I can understand what a function does. Maybe not where the modder or the game calls that function but I can call it myself and use it.
But to code it by myself and create my own custom functions... mehh that's on another level.
(I admit I would feel a bit overwhelmed.)
DaveMcW wrote: Sat Jan 13, 2024 6:43 pm In your mod's data.lua write:
Awelsome. Never would have thought of that, as functions and codes that use tables are not my best.
I really thank you for your time.

That's what I mean Qon: Tables are another thing that I don't really understand - how deepcopy, insertions ecc. work.
And despite time is not this much I tried to learn, you can be sure - and I learned something for example about the difference between data.lua / final-fixes / updates and how the game proceeds to compile the mod files. I'm proud I'm finally able to understand how events work (at a certain degree, yeah, but still progress.) and work around them to update recipes.
But still I see that many things are missing...

Sorry again for the late reply, and again thank you all for the time and the responses.