doomeer / factorio

Factorio Planner
MIT License
137 stars 40 forks source link

Productivity percentage should only apply on supported products #11

Closed wischi-chr closed 5 years ago

wischi-chr commented 7 years ago

Not every product supports productivity modules. Take science 2 for example and enter 1 sciene2 / s and add 40% productivity bonus. 0.715 Inserters/s need only 0.511 iron / s but thats not true, because inserters don't support productivity.

Would be great if productivity bonus is only applied on supported products. Supported products are listed in this file:

/factorio/data/base/prototypes/item/module.lua

function productivitymodulelimitation()
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",
        "wood",
        "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",
        "rocket-control-unit",
        "rocket-part",
        "science-pack-1",
        "science-pack-2",
        "science-pack-3",
        "military-science-pack",
        "production-science-pack",
        "high-tech-science-pack"
      }
end
doomeer commented 7 years ago

Thanks for the list, it will be useful!

Sadumon commented 7 years ago

I handled this by adding another property to the resource list, productivityallowed, as a float. Defaulted it to 0, but set it to 1 for any item in the above list. Then just multiplied productivity_bonus in line 441 of factoriojs.ml by resource.productivityallowed.

doomeer commented 7 years ago

Done!

Thanks Sadumon for the implementation idea, this helped! I did almost exactly as you suggest.

werelord commented 7 years ago

Is this working on the current published version?? I just tested by hand for science pack 2, any increase in prod% changes the # of yellow inserter assemblies..

Grokzen commented 7 years ago

Would like to report that speed modules lv 1 suffers from this problem also. It do not support prod modules but people stick x4 extra speed mods and when i change the speed bonus for assembly machines it affects all subitems as well and cause the calculations to be wrong.

doomeer commented 7 years ago

@werelord and @Grokzen : it seems to me that it is working fine.

I tested with science pack 2. If I set productivity bonus to 100%, it requires half as many inserters, not because inserters benefit from the productivity bonus but because the science pack does, so producing the same amount of science packs requires half the amount of inserters :)

Or maybe you are not using http://www.doomeer.com/factorio but https://dwahler.github.io/factorio ? I don't know if this clone is up-to-date.