diff --git a/config.lua b/config.lua index 156850cb..86f26a40 100644 --- a/config.lua +++ b/config.lua @@ -416,6 +416,12 @@ global.config = { ['refined-flammables'] = {{turret_type = 'fluid-turret', amount = 60 * 17 / 7}}, ['artillery-shell-speed'] = {{turret_type = 'artillery-turret', amount = 60 * 2}} } + }, + research_printer = { + enabled = true, + print_to_force = true, -- print a message to force chat when that force finishes a new research. + print_to_discord = true, -- print a message to the discord channel when the player force finishes a new research. + ignore_script = false -- ignore researches unlocked by commands or by code. } } diff --git a/control.lua b/control.lua index 27ec1e64..9677bcca 100644 --- a/control.lua +++ b/control.lua @@ -106,6 +106,9 @@ end if config.autofill.enabled then require 'features.gui.autofill' end +if config.research_printer then + require 'features.research_printer' +end -- GUIs -- The order determines the order they appear from left to right. diff --git a/features/research_printer.lua b/features/research_printer.lua new file mode 100644 index 00000000..d55fb02c --- /dev/null +++ b/features/research_printer.lua @@ -0,0 +1,27 @@ +local Event = require 'utils.event' +local Server = require 'features.server' + +local to_discord_bold = Server.to_discord_bold +local config = global.config.research_printer +local template = {'research_printer.research_finish', nil} + +local function research_finished(event) + if config.ignore_script and event.by_script then + return + end + + local research = event.research + local research_name = research.name + local force = research.force + + if config.print_to_force then + template[2] = research_name + force.print(template) + end + + if config.print_to_discord and force.name == 'player' then + to_discord_bold(research_name .. ' has been researched.') + end +end + +Event.add(defines.events.on_research_finished, research_finished) diff --git a/locale/en/redmew_features.cfg b/locale/en/redmew_features.cfg index 33a1786f..4d9075a7 100644 --- a/locale/en/redmew_features.cfg +++ b/locale/en/redmew_features.cfg @@ -162,6 +162,9 @@ invalid_ammo_count=ammo count must be a positive integer main_button_tooltip=Autofill settings frame_name=Autofill +[research_printer] +research_finish=[technology=__1__] has been researched. + [snake] name=Snake spawn_snake_fail=Unable to spawn snake, please try again.