From 71870daabaf1a181eb73242c4d60bc26cb0a2f14 Mon Sep 17 00:00:00 2001 From: psihius Date: Sun, 14 Jul 2019 15:00:55 +0200 Subject: [PATCH] Made so mass tech sync does not make sounds or messages, only notifies at the end --- sharedPlugins/researchSync/enableResearch.lua | 24 ++++++++++--------- sharedPlugins/researchSync/index.js | 4 ++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sharedPlugins/researchSync/enableResearch.lua b/sharedPlugins/researchSync/enableResearch.lua index 2e9da5c0..155a8ecc 100644 --- a/sharedPlugins/researchSync/enableResearch.lua +++ b/sharedPlugins/researchSync/enableResearch.lua @@ -1,15 +1,17 @@ /silent-command 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 - script.raise_event(defines.events.on_research_finished, {research=game.forces['player'].technologies['{tech_name}'], by_script=true}) - game.play_sound({path="utility/research_completed"}) if 1 == {tech_infinite} then - game.print("Infinite technology {tech_name} level {tech_level} unlocked") - else - game.print("Technology {tech_name} researched") - end + game.forces['player'].technologies['{tech_name}'].level = {tech_level} + else + game.forces['player'].technologies['{tech_name}'].researched = true + end + 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 + game.print("Infinite technology {tech_name} level {tech_level} unlocked") + else + game.print("Technology {tech_name} researched") + end + game.play_sound({path="utility/research_completed"}) + end end diff --git a/sharedPlugins/researchSync/index.js b/sharedPlugins/researchSync/index.js index ab676364..adb811d5 100644 --- a/sharedPlugins/researchSync/index.js +++ b/sharedPlugins/researchSync/index.js @@ -80,6 +80,8 @@ class ResearchSync { let difference = this.filterResearchDiff(this.research, needResearch); + let count = Object.keys(difference).length; + let counter = 1; Object.keys(difference).forEach((key) => { if (this.research[key]) { let command = this.functions.enableResearch; @@ -88,6 +90,7 @@ class ResearchSync { command = command.replace("{tech_researched}", difference[key].researched); command = command.replace("{tech_level}", difference[key].level); command = command.replace("{tech_infinite}", difference[key].infinite); + command = command.replace("{notify}", count > 1 || count === counter ? 'false' : 'true'); } this.messageInterface(command); let log_message = ''; @@ -99,6 +102,7 @@ class ResearchSync { console.log(log_message); this.messageInterface(log_message); this.research[key] = difference[key]; + ++counter; } });