Crafting Efficiency


Adds technology to increase the efficiency of some recipes, auto updates recipes in assembly machines and adds a function for modders to add efficiency recipes for their items

Content
a month ago
1.1
3.23K
Manufacturing

g Bug with non sequential fluid ingredients/results

a month ago

Hey Grifonice99,

I'm reporting a strange bug I ran into yesterday (and then again with the update), and sharing my fix for it. You have a recipe that takes multiple fluid inputs and/or outputs, and I guess through a combination of mods, has the keys set to 1, 2, 3, 5. When you recreate the ingredients/results tables, you use the table.insert method, so the result table ends up with keys 1,2,3, 4. At around line 265-270 in prototypes/recipes.lua, you loop over the base ingredients/results table to set fluidbox_index on the new table. This fails because a (from the base) is 5 and the result table has no index 5, the last being 4. I've solved this by setting a local idx to 1 outside of the loop, and then at the end of the loop, before the end statement, adding idx = idx + 1 and ignoring a. I did this for both ingredients and results (as both showed the same error).

a month ago
    if CE_recipes[name].base.ingredients then
        local idx = 1
        for a, b in pairs(CE_recipes[name].base.ingredients) do
            if b.type == "fluid" then
                recipe.normal.ingredients[idx].fluidbox_index = b.fluidbox_index
                recipe.expensive.ingredients[idx].fluidbox_index = b.fluidbox_index
            end
            idx = idx + 1
        end
    end
    if CE_recipes[name].base.results then
        local idx = 1
        for a, b in pairs(CE_recipes[name].base.results) do
            if b.type == "fluid" then
                recipe.normal.results[idx].fluidbox_index = b.fluidbox_index
                recipe.expensive.results[idx].fluidbox_index = b.fluidbox_index
            end
            idx = idx + 1
        end
    end
a month ago

Thank you for the bug fix, I will now release the update with the patch.

a month ago

Thank you for the quick turnaround, and my pleasure this was a fun bug to investigate and fix :)

New response