From cf95bcfc6231528ced501ba44da7224128bd2d10 Mon Sep 17 00:00:00 2001 From: plague006 Date: Sat, 10 Nov 2018 23:58:57 -0500 Subject: [PATCH 1/2] Split donator/on_join messages out of control --- control.lua | 16 +--------------- features/donator_messages.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 features/donator_messages.lua diff --git a/control.lua b/control.lua index d3fc89c8..dd618f04 100644 --- a/control.lua +++ b/control.lua @@ -31,9 +31,9 @@ require 'blueprint_helper' require 'paint' require 'score' require 'popup' +require 'features.donator_messages' local Event = require 'utils.event' -local Donators = require 'resources.donators' local function player_created(event) local player = Game.get_player_by_index(event.player_index) @@ -161,22 +161,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..5be4d6e1 --- /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) \ No newline at end of file From 27bc52680e5da57b7a20611171cdf9aac8b81038 Mon Sep 17 00:00:00 2001 From: plague006 Date: Sun, 11 Nov 2018 10:12:04 -0500 Subject: [PATCH 2/2] Add newline to eof --- features/donator_messages.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/donator_messages.lua b/features/donator_messages.lua index 5be4d6e1..288448ed 100644 --- a/features/donator_messages.lua +++ b/features/donator_messages.lua @@ -16,4 +16,4 @@ local function player_joined(event) game.print(table.concat({'*** ', message, ' ***'}), player.chat_color) end -Event.add(defines.events.on_player_joined_game, player_joined) \ No newline at end of file +Event.add(defines.events.on_player_joined_game, player_joined)