[Question] Are these doable via modding?

Place to post guides, observations, things related to modding that are not mods themselves.
Imperio
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun May 14, 2017 3:54 pm
Contact:

[Question] Are these doable via modding?

Post by Imperio »

I'm looking to get my hands dirty in modding, and I have some ideas. I'm not entirely sure however if all these ideas are even possible to be implemented, so before I bang my head against the wall, some pointers from veterans would be appreciated!

1) You already can change the productivity of recipes via teching. Can you also affect other attributes, such as crafting time, pollution, energy usage, or quality?

2) Likewise, can you manipulate entities directly via teching, such as adding a base productivity bonus, base speed bonus, or base quality bonus to an assembling machine?

3) Could you also alter entities more significantly via teching, such as allowing fluid ingredients in an assembling machine, adding module slots, or modifying transport belt speed?

In 2) and 3), I'm basically asking if you can change the properties of entities during runtime, by whatever trigger that may be. Teching would be the logical choice here.

4) Can you alter recipes during runtime? E.g. have Steel Plate require only 4 Iron Plates instead of 5, with all existing instances of that recipe being automatically updated?

5) Can you change the way Quality bonuses are applied to different entities? Specifically, can you explicitly state the effects of each quality tier for any entity, without it having to be linear?

6) Would it be possible to assign the pollution and energy usage values on a per-recipe basis, so that those are then tied to the recipe, not to the machine making that recipe? Basically I'm looking to turn those upside down so that the pollution and energy would be constant (like crafting time currently is), and machines could then have modifiers to those values (like crafting speed can be modified).

Thank you in advance!
Imperio
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun May 14, 2017 3:54 pm
Contact:

Re: [Question] Are these doable via modding?

Post by Imperio »

I tried looking at the game files themselves. I have some knowledge of programming in C++ and Python, and while Lua itself is alien to me, the structure of these files seems rather straightforward. Reminds me of modding Rome: Total War game files some 20 years back to make archers fire onager projectiles. :)

Anyway, from Factorio\data\space-age\prototypes\technology.lua:

Code: Select all

  {
    type = "technology",
    name = "rocket-part-productivity",
    icons = util.technology_icon_constant_recipe_productivity("__space-age__/graphics/technology/rocket-part-productivity.png"),
    icon_size = 256,
    effects =
    {
      {
        type = "change-recipe-productivity",
        recipe = "rocket-part",
        change = 0.1
      }
    },
    prerequisites = {"cryogenic-science-pack"},
    unit =
    {
      count_formula = "1.5^L*2000",
      ingredients =
      {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
        {"chemical-science-pack", 1},
        {"production-science-pack", 1},
        {"cryogenic-science-pack", 1},
      },
      time = 60
    },
    max_level = "infinite",
    upgrade = true
  }
There, under effects, the

Code: Select all

type = "change-recipe-productivity"
is interesting to me for at least 2 reasons discussed in the original post:

1) If there is an effect type "change-recipe-productivity", do similar types "change-recipe-speed", "change-recipe-quality" etc. also exist?

2) If there is an effect type "change-recipe-productivity", is there a similar type also affecting entities instead of recipies?

is there some library where I can see what effect types exist? And if they do not exist natively, is there any means to add such effect types? I'm under the impression Factorio modding is very flexible, and I would think such trivial things would already be supported.
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: [Question] Are these doable via modding?

Post by Silari »

API documentation exists at https://lua-api.factorio.com/latest/index.html - there's a link at the top of the page. All the available modifiers are at https://lua-api.factorio.com/latest/types/Modifier.html - if it's not listed there, it's not possible to do it via technology effects.

There's no other recipe effects other than productivity available.

You can fake some effects by using control stage scripting, but results usually aren't going to be very good unless they're one time things.

You can't alter prototypes during run time, so no changing ingredients of a recipe. For 5, what you CAN do is have the technology unlock the new recipe, then use scripting to disable the old recipe for the force and manually swap the recipe of any placed entity to the new one. As it's a one-time swap, it shouldn't be a problem to do that with scripting.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 189
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: [Question] Are these doable via modding?

Post by Osmo »

1) No, only productivity technology effect exists, as has been said above.
2) No, you can change all base effects, but not at runtime.
3) You could enable and disable some recipes at runtime, which could be used to change whether reipes with fluids are available, for example, but not most other properties.
4) As has been said, you can make multiple recipes and swap their enabled/disabled state, and change the recipe of every existing machine to the new one.
5) Depends. You can change global value per each quality protype https://lua-api.factorio.com/latest/pro ... otype.html . These apply to all other protoypes, but select few properties can be changed on a per-protoype basis, for example the module slots bonus https://lua-api.factorio.com/latest/pro ... lity_bonus
6) Energy usage of a recipe controls only how long it takes, and doesn't affect energy consumption, but you can change pollution multipler of a recipe https://lua-api.factorio.com/latest/pro ... multiplier
Imperio
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun May 14, 2017 3:54 pm
Contact:

Re: [Question] Are these doable via modding?

Post by Imperio »

API documentation exists at https://lua-api.factorio.com/latest/index.html - there's a link at the top of the page. All the available modifiers are at https://lua-api.factorio.com/latest/types/Modifier.html - if it's not listed there, it's not possible to do it via technology effects.
Thanks! Will use that as a reference.
There's no other recipe effects other than productivity available.
No, only productivity technology effect exists, as has been said above.
Huh, I'm a bit surprised by this. I would have thought such effects would have been trivial to implement, even if there was no plan to use them in the end.
No, you can change all base effects, but not at runtime.
You can fake some effects by using control stage scripting, but results usually aren't going to be very good unless they're one time things.
Well damn. Need to get creative then... Maybe if there are dummy versions of each entity "tier" under the hood, and each time an improvement is enabled, a script would update each existing instance to the new one?
Bad news is, if there would be technologies to modify multiple attributes, I would need A^N different versions, where A is the # of tech increases, and N is the # of attributes I would like to change. So if I wanted to increment productivity, speed, energy consumption and quality for 10 levels, I would need 10^4 = 10000 different versions...
I wonder If I could create new entities during runtime, dynamically? ;)
As has been said, you can make multiple recipes and swap their enabled/disabled state, and change the recipe of every existing machine to the new one.
You can't alter prototypes during run time, so no changing ingredients of a recipe. For 5, what you CAN do is have the technology unlock the new recipe, then use scripting to disable the old recipe for the force and manually swap the recipe of any placed entity to the new one. As it's a one-time swap, it shouldn't be a problem to do that with scripting.
Ok, this is reassuring at least. I think this could work to also modify the recipe attributes, like give speed/quality boosts.
Depends. You can change global value per each quality protype https://lua-api.factorio.com/latest/pro ... otype.html . These apply to all other protoypes, but select few properties can be changed on a per-protoype basis, for example the module slots bonus https://lua-api.factorio.com/latest/pro ... lity_bonus
Oh damn, it's done like that? No wonder the Big Electric Pole and Substation scaling felt so wonky... one of the things I would have wanted to adjust, make Big poles gain substantially more length per tier, rather than increase the distribution area.
Would it be technically possible to assign each entity a unique prototype, to adjust the settings for each tier of each entity explicitly? And more than that, would it be feasible?
Energy usage of a recipe controls only how long it takes, and doesn't affect energy consumption, but you can change pollution multipler of a recipe https://lua-api.factorio.com/latest/pro ... multiplier
Yeah, my point is that currently the energy consumption and pollution are properties of the assembler, while realistically they should be properties of the recipe. When playing Bob's Mods I always felt disturbed by the amount of cheap Hydrogen you could get from Water Electrolysis, when in reality that process takes a massive amount of energy. I know you can give individual recipes modifiers to energy consumption and pollution, but that just feels like a roundabout way...

But anyway, thanks for your help! I might post more noob questions later. ;)
eugenekay
Filter Inserter
Filter Inserter
Posts: 845
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: [Question] Are these doable via modding?

Post by eugenekay »

Imperio wrote: Thu Nov 06, 2025 8:22 pmWould it be technically possible to assign each entity a unique prototype, to adjust the settings for each tier of each entity explicitly? And more than that, would it be feasible?
More Quality Scaling uses this technique to create a (hidden) entity for each Quality Tier with extended Range, Capacity etc; then it fast-replaces using the Events system.
11-06-2025, 15-28-02.png
11-06-2025, 15-28-02.png (189.51 KiB) Viewed 30 times
Good Luck!
Post Reply

Return to “Modding discussion”