fix no recipe module insertion

This commit is contained in:
2023-09-30 18:40:15 +09:00
parent 832ff0acef
commit 4015e5058a
2 changed files with 21 additions and 5 deletions

View File

@@ -5,6 +5,15 @@ return {
machine_prod_disallow = {
['beacon'] = true
},
machine_craft = {
['assembling-machine-2'] = true,
['assembling-machine-3'] = true,
['electric-furnace'] = true,
['oil-refinery'] = true,
['chemical-plant'] = true,
['centrifuge'] = true,
['rocket-silo'] = true
},
machine = {
['electric-mining-drill'] = 'effectivity-module',
['assembling-machine-2'] = 'productivity-module',

View File

@@ -123,15 +123,22 @@ end
local function apply_module(player, area, machine, module)
for _, entity in pairs(player.surface.find_entities_filtered{area=area, name=machine, force=player.force}) do
if config.machine_craft[machine] ~= nil then
if config.machine_craft[machine] then
local m_current_recipe = entity.get_recipe()
-- insert
if m_current_recipe ~= nil then
if module_allowed[m_current_recipe.name] ~= nil then
if module_allowed[m_current_recipe.name] then
entity.surface.create_entity{name='item-request-proxy', target=entity, position=entity.position, force=entity.force, modules=module}
end
end
else
entity.surface.create_entity{name='item-request-proxy', target=entity, position=entity.position, force=entity.force, modules=module}
end
end
else
entity.surface.create_entity{name='item-request-proxy', target=entity, position=entity.position, force=entity.force, modules=module}
end