mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Fix auto research queue (#329)
This commit is contained in:
@@ -8,12 +8,13 @@ Global.register(research, function(tbl)
|
|||||||
research = tbl
|
research = tbl
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function res_queue(force, res, by_script)
|
local function res_queue(force, by_script)
|
||||||
local res_q = force.research_queue
|
local res_q = force.research_queue
|
||||||
|
local res = force.technologies['mining-productivity-4']
|
||||||
|
|
||||||
if #res_q < config.queue_amount then
|
if #res_q < config.queue_amount then
|
||||||
for i=1, config.queue_amount - #res_q do
|
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
|
if not (by_script) then
|
||||||
game.print{'expcom-res.inf-q', res.name, res.level + i}
|
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
|
research.res_queue_enable = not research.res_queue_enable
|
||||||
|
|
||||||
if research.res_queue_enable then
|
if research.res_queue_enable then
|
||||||
res_queue(player.force, nil, true)
|
res_queue(player.force, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
game.print{'expcom-res.res', player.name, research.res_queue_enable}
|
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)
|
Event.add(defines.events.on_research_finished, function(event)
|
||||||
if research.res_queue_enable then
|
if research.res_queue_enable then
|
||||||
if event.research.force.rockets_launched > 0 and event.research.force.technologies['mining-productivity-4'].level > 4 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
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user