Fix for__pycoalprocessing__/prototypes/functions/functions.lua:383: attempt to index field 'expensive' (a boolean value)

pyanodon's mods are here

Moderator: pyanodon

Post Reply
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Fix for__pycoalprocessing__/prototypes/functions/functions.lua:383: attempt to index field 'expensive' (a boolean value)

Post by matjojo »

I'm working on compatibility between your mods and mine. My mod generates a whole host of recipes that have expensive and normal modes. The handling of these modes in the prototypes.functions.functions.lua file is wrong due to a faulty assumption.

The `expensive` and `normal` fields of recipes can be either nil, false, or Recipedata. The function overrides.ingredient_replace function, lines 377 to 384:

Code: Select all

                elseif recipe.normal or recipe.expensive then
                    --log(serpent.block(recipe))
                    if recipe.normal ~= nil then
                        --log("is check good")
                        ningredients = recipe.normal.ingredients
                    end
                    if recipe.expensive ~= nil then eingredients = recipe.expensive.ingredients end
In both the inner if statements the assumption is made that ~= nil implies that the field is a Recipedata, but it can also be `false`. It can be set to false to disable said recipe in a mode.

The solution here is to remove the `~= nil` part of the if statement. I have made that patch in a local copy of the mod, and that solves the issue.

If there is someplace I can send a patch or a pull request I'd be happy to, but I can't find anything of the sort.

kingarthur
Smart Inserter
Smart Inserter
Posts: 1459
Joined: Sun Jun 15, 2014 11:39 am
Contact:

Re: Fix for__pycoalprocessing__/prototypes/functions/functions.lua:383: attempt to index field 'expensive' (a boolean va

Post by kingarthur »

ok. its pretty much guaranteed that i missed several edges cases like that. if you already know exactly what needs fixed you can make a pull request on the git. https://github.com/pyanodon or just dm me the file(s) in question

matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: Fix for__pycoalprocessing__/prototypes/functions/functions.lua:383: attempt to index field 'expensive' (a boolean va

Post by matjojo »

Ah! I hadn't seen that account. Will send a pull request.

Post Reply

Return to “PyMods”