From 5135ef9bd9a824aac78b9fc62b9bac74fe188bb7 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 21 Sep 2024 06:33:53 +0900 Subject: [PATCH] Fix auto research queue (#329) --- modules/commands/research.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/commands/research.lua b/modules/commands/research.lua index 3f75447c..bc05741c 100644 --- a/modules/commands/research.lua +++ b/modules/commands/research.lua @@ -8,12 +8,13 @@ Global.register(research, function(tbl) research = tbl end) -local function res_queue(force, res, by_script) +local function res_queue(force, by_script) local res_q = force.research_queue + local res = force.technologies['mining-productivity-4'] if #res_q < config.queue_amount then for i=1, config.queue_amount - #res_q do - force.add_research(force.technologies['mining-productivity-4']) + force.add_research(res) if not (by_script) then game.print{'expcom-res.inf-q', res.name, res.level + i} @@ -28,7 +29,7 @@ Commands.new_command('auto-research', {'expcom-res.description-ares'}, 'Automati research.res_queue_enable = not research.res_queue_enable if research.res_queue_enable then - res_queue(player.force, nil, true) + res_queue(player.force, true) end game.print{'expcom-res.res', player.name, research.res_queue_enable} @@ -38,7 +39,7 @@ end) Event.add(defines.events.on_research_finished, function(event) if research.res_queue_enable then if event.research.force.rockets_launched > 0 and event.research.force.technologies['mining-productivity-4'].level > 4 then - res_queue(event.research.force, {name=event.research.name, level=event.research.level}, event.by_script) + res_queue(event.research.force, event.by_script) end end end)