Module Inserter


Mass insert modules into machines with construction bots

Utilities
a month ago
0.13 - 1.1
140K

b Productivity modules can not be inserted in 0.16.23.

6 years ago
(updated 6 years ago)

It was working fine in version 0.16.22, but now, productivity modules can not be inserted. It considers any item as being "NOT intermediate items".

6 years ago

Having same problem, anything fixed soon? Mod is broken as of now..

6 years ago
(updated 6 years ago)

Good news: I have a fix.

In control.lua, line 154, the following code is present to detect if you can insert productivity modules into a machine:

    if entity.type == "assembling-machine" and recipe and next(prototype.limitations) and not 
    prototype.limitations[recipe.name] then
        player.print({"", "Can't use ", prototype.localised_name, " with recipe: ", recipe.localised_name})
        valid_modules = false
    end

The problem is that the author tries to check if a recipe is not in prototype.limitations by indexing it with the name: it doesn't check if recipe.name is in the array, it checks if it has a key with the name of recipe.name, which it never does since it is a normal array. So this check always evaluates to nil, and not nil is true, so you can't insert productivity modules into any machine. To fix this, I just iterated through the array normally to check if recipe.name is in there. If you replace the previous code with this code:

    if entity.type == "assembling-machine" and recipe and next(prototype.limitations) then
        valid_modules = false
        for _, module_limitation in pairs(prototype.limitations) do
            if recipe.name == module_limitation then
                valid_modules = true
            end
        end
        if valid_modules == false then
            player.print({"", "Can't use ", prototype.localised_name, " with recipe: ", recipe.localised_name})
        end
    end

then it works. I have tested this personally.

New response