diff --git a/control.lua b/control.lua index 340d68d9..9fc4628b 100644 --- a/control.lua +++ b/control.lua @@ -45,7 +45,9 @@ require 'features.gui.blueprint_helper' require 'features.gui.paint' require 'features.gui.score' require 'features.gui.popup' +require 'features.donator_messages' +local Event = require 'utils.event' local function player_created(event) local player = Game.get_player_by_index(event.player_index) @@ -173,22 +175,8 @@ local function hodor(event) end end -local function player_joined(event) - local player = Game.get_player_by_index(event.player_index) - if not player or not player.valid then - return - end - - local message = Donators.welcome_messages[player.name] - if not message then - return - end - - game.print(table.concat({'*** ', message, ' ***'}), player.chat_color) -end Event.add(defines.events.on_player_created, player_created) -Event.add(defines.events.on_player_joined_game, player_joined) Event.add(defines.events.on_console_chat, hodor) Event.add( diff --git a/features/donator_messages.lua b/features/donator_messages.lua new file mode 100644 index 00000000..288448ed --- /dev/null +++ b/features/donator_messages.lua @@ -0,0 +1,19 @@ +local Game = require 'utils.game' +local Event = require 'utils.event' +local Donators = require 'resources.donators' + +local function player_joined(event) + local player = Game.get_player_by_index(event.player_index) + if not player or not player.valid then + return + end + + local message = Donators.welcome_messages[player.name] + if not message then + return + end + + game.print(table.concat({'*** ', message, ' ***'}), player.chat_color) +end + +Event.add(defines.events.on_player_joined_game, player_joined)