Productivity Research for Everyone

by Semenar

Adds a productivity research for every recipe that supports productivity and does not already have one.

Tweaks
3 months ago
2.0
1.42K
Manufacturing

b Some bug fixes

a month ago

Not sure exactly what mods were causing these bugs, but in functions.lua:

function ProductivityResearchForEveryone.rescaleIcons(icons, rescale_mod)
    for _, icon in pairs(icons) do
        if icon.scale then
            icon.scale = icon.scale * rescale_mod
            if icon.shift then
                -- Per https://lua-api.factorio.com/latest/types/IconData.html, this can be either a 2-element vector, or a struct {x, y}
                if (icon.shift[1] ~= nil) then
                    icon.shift[1] = icon.shift[1] * rescale_mod
                    icon.shift[2] = icon.shift[2] * rescale_mod
                else
                    icon.shift.x = icon.shift.x * rescale_mod
                    icon.shift.y = icon.shift.y * rescale_mod
                end
            end
        end
    end
end
function ProductivityResearchForEveryone.isTechSimplerThan(tech, other_tech)

    -- after prereq bias, before pack type count

    -- ignore techs with no unit ingredients.
    -- This is 100% a bug in another mod but I wasn't able to figure out which mod was causing the bug
    if (tech.unit.ingredients ~= nil) and not (other_tech.unit.ingredients ~= nil) then
        return true
    end
    if not (tech.unit.ingredients ~= nil) and (other_tech.unit.ingredients ~= nil) then
        return false
    end
    if (tech.unit.ingredients == nil) and (other_tech.unit.ingredients == nil) then
        return false
    end

(I'm not really familiar with lua, there might be better ways to handle these checks)

27 days ago

Thanks, noted, I will implement that when I have free time.
The first change is definitely valid; not sure about the second one since Lua API does say the "ingredients" field is not optional. I guess I can do a pass replacing nil-s with empty arrays instead.

New response