Mirrored Fluid Inputs / Outputs

by Resnox

Ever been tired of input or outputs of fluid being awfully badly placed ? Fear not, this mod is there to help you chose the inputs/outputs you exactly want, not just mirroring the recipe, you have access to any kind of combination ! (This mod should be compatible with every mods but could take long to load depending on how many mods you have (Should be less than a second tho))

Utilities
3 years ago
0.18
9

i Allowing Productivity Modules

3 years ago
(updated 3 years ago)

I find this mod great, but it doesn't allow productivity modules to be used with the new recipes that it generates. The code below fixes that and allows any newly generated recipes to use productivity modules if the original recipe did. Hopefully the author can take this code and add the feature.

Modify recipe-generator.lua to be the following (starting at line 82). There are two edits here, the "Figure out if" part and then inside the loop the "Add to" part. There are similar edits farther down in the file near line 286.


    -- Figure out if productivity modules should be allowed
    local add_to_productivity = false
      for _, prod_recipe_name in pairs(data.raw.module["productivity-module"].limitation) do
            if prod_recipe_name == recipe.name then
                 add_to_productivity = true
            end
      end

    -- Just gonna increase the count to make the recipes always unique (it cause error otherwise !)
    local mirror_version = 0
    for i, ip in ipairs(inputsPermutations) do
        for j, op in ipairs(outputsPermutations) do
            -- Skipping the first permutation as this is the classic recipe
            if i ~= 1 or j ~= 1 then
                local new_recipe = util.table.deepcopy(recipe);
                new_recipe.name = new_recipe.name .. "-mirrored-" ..
                                      mirror_version

                new_recipe.ingredients = ip
                new_recipe.results = op
                if new_recipe.result then
                    new_recipe.result = nil
                    new_recipe.result_count = nil
                end

                -- The recipe is always available but it's hidden behind the shortcut system to avoid having 20 recipes of the same thing in the crafting menu...
                new_recipe.enabled = true
                new_recipe.hidden = true

                -- We retrieve the localised name of the recipe that we permute
                new_recipe.localised_name = {"recipe-name." .. recipe.name};

                -- Add to the productivity list if needed
                if add_to_productivity then
                    table.insert(data.raw["module"]["productivity-module"].limitation, new_recipe.name)
                    table.insert(data.raw["module"]["productivity-module-2"].limitation, new_recipe.name)
                    table.insert(data.raw["module"]["productivity-module-3"].limitation, new_recipe.name)
                end

                table.insert(recipes, new_recipe);
                mirror_version = mirror_version + 1
            end
        end
    end

New response