Auto Research (fixed + re-published abandoned mod)


Automates research. Toggle GUI with Shift+T (customizable).

Utilities
1 year, 2 days ago
0.18 - 2.0
32.4K

g feature request: sort techs by chosen strategy

25 days ago

In the searchable list of techs at the bottom of the Auto Research search UI, I think it would be neat if they were automatically sorted by whatever tech-picking strategy the user currently has selected, so they can see what's coming up next.

17 days ago

The techs are sorted by some internal game logic and I would need to duplicate that logic first to make it possible to change the sorting.

The code is already messy AF and I dont see a way to easily add that - it would require a full rewrite of the code that displays the filter results.

I fear im not doing that anytime soon.

17 days ago

I've got it working in my local branch; if you think this feature would be valuable aside from the implementation effort, let me know how I can contribute! Otherwise, I'm content that it works for me.

17 days ago

Inside updateSearchResult I stuff the techs into a temporary table before iterating over them, sort them according to the same effort function used to select next tech, and then iterate over that sorted table:

<...>
        -- NOTICE: localised name matching does not work at present, pending unlikely changes to Factorio API
        techs = {}
        for name, tech in pairs(player.force.technologies) do
            table.insert(techs, {name, tech})
        end
        sortTechsByEffort(techs, config)
        for _, namedTech in pairs(techs) do
<...>
function sortTechsByEffort(techs, config)
    local compare = function(a, b)
        print(a)
        return calcEffort(a[2], config) < calcEffort(b[2], config)
    end
    table.sort(techs, compare)
    return
end

There are probably more idiomatic ways to do this, but it didn't require me to replicate the internal game sorting logic.

17 days ago

(I should probably also figure out how to trigger updateSearchResult when the selected prioritization strategy changes!)

New response