From 042230dc2c106b4ecf626e424f728a359a10087d Mon Sep 17 00:00:00 2001 From: Sander Homan Date: Mon, 29 Jul 2019 20:31:42 +0200 Subject: [PATCH] Fix notifying about the same research being finished This is just a bandaid to fix a symptom. The underlying cause is still there, but at least it shouldn't spam the players anymore. --- sharedPlugins/researchSync/enableResearch.lua | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sharedPlugins/researchSync/enableResearch.lua b/sharedPlugins/researchSync/enableResearch.lua index 4e5af42a..f83a1e93 100644 --- a/sharedPlugins/researchSync/enableResearch.lua +++ b/sharedPlugins/researchSync/enableResearch.lua @@ -1,10 +1,5 @@ -if game.forces['player'].technologies['{tech_name}'] then - if 1 == {tech_infinite} then - game.forces['player'].technologies['{tech_name}'].level = {tech_level} - else - game.forces['player'].technologies['{tech_name}'].researched = true - end +local function updateTech() script.raise_event(defines.events.on_research_finished, {research=game.forces['player'].technologies['{tech_name}'], by_script=true}) if {notify} then if 1 == {tech_infinite} then @@ -15,3 +10,17 @@ if game.forces['player'].technologies['{tech_name}'] then game.play_sound({path="utility/research_completed"}) end end + +if game.forces['player'].technologies['{tech_name}'] then + if 1 == {tech_infinite} then + if (game.forces['player'].technologies['{tech_name}'].level ~= level) then + game.forces['player'].technologies['{tech_name}'].level = {tech_level} + updateTech() + end + else + if not game.forces['player'].technologies['{tech_name}'].researched then + game.forces['player'].technologies['{tech_name}'].researched = true + updateTech() + end + end +end