Recipes Reload

by AivanF

This mod does one simple thing: it reloads researched recipes when new mods get added or updated. Unfortunately, Factorio doesn't do this by default. Some mods forget doing this and you get missing recipes, other ones add the same script, but duplication leads to performance degradation. So this mods intended to be a dependency for single recalculation of researched technologies results. It works automatically, but you can also call it manually with /recipes-reload command.

Tweaks
9 months ago
1.1
3.91K

i Every mod author should do this in their own mods

9 months ago
(updated 9 months ago)

You mod is a good temporary solution in such case,
But every mod author should do this in this own mod. so there should be no need to have an extra mod permanently installed.

local function reload_recipes()
    for i, force in pairs(game.forces) do
        for _, tech in pairs(force.technologies) do
            if tech.researched then
                for _, effect in pairs(tech.effects) do
                    if effect.type == "unlock-recipe" and 
                        not force.recipes[effect.recipe].enabled and
                        script.get_prototype_history("recipe", effect.recipe).created == script.mod_name                    
                    then
                        --print("Enabling recipe: "..effect.recipe)
                        force.recipes[effect.recipe].enabled = true
                    end
                end
            end
        end
    end
end

script.on_configuration_changed(function ()
    reload_recipes()
end)

MIT License for this code. because not every one can use LGPL. ;-)

best regards
Kux

9 months ago

Hah, yeah, this sounds more robust! But 1. I doubt that most mod devs will remember to do this, 2. all the mods with such script will iterate over all the technologies each time a configuration gets changes, which is bad for performance of game save loading time, so it's better to do in one place.

Speaking of licenses, I don't think they relate to such small and simple scripts πŸ€”

9 months ago

you are already right it's just an alternative to do it only for a specific mod.
and because the license, I just wanted to say If you want to allow your code to be reused, MIT is the way to go. LGPL has some limitations. Even if it is only a little code and some developers don't care about the license. :-)

New response