Productivity Technology Limit


Appropriately limits the maximum level of infinite technologies that grant productivity bonuses.

Tweaks
7 months ago
2.0
277

b Stack overflow

3 months ago

I got a stack overflow when starting a modpack including PTL:

data-final-fixes.lua:8: stack overflow
stack traceback:
data-final-fixes.lua:8 in function "compute_prereqs"
data-final-fixes.lua:15 in ~
...
3 months ago

One way to fix the issue:

function compute_prereqs(techs, recipe, history)
    history = history or {}
    local res = 0
    for _, tech_name in pairs(techs) do
        if not history[tech_name] then
            history[tech_name] = 1
            local tech = data.raw["technology"][tech_name]
            for _, e in pairs(tech.effects or {}) do
                if e.type == "change-recipe-productivity" and e.recipe == recipe then
                    unimplemented(tech.max_level ~= nil,
                        "Prequisite technology " .. tech.name .. " can be researched " .. tostring(tech.max_level) .. " times")
                    res = res + e.change end end
            res = res + compute_prereqs(tech.prerequisites or {}, recipe, history) end
        end
    return res end
    ...
a month ago

nice one!!!

New response