2018-08-07 11:33:46 +01:00
|
|
|
local Event = require 'utils.event'
|
2018-09-22 23:25:13 +01:00
|
|
|
local Game = require 'utils.game'
|
2018-11-10 21:43:11 -05:00
|
|
|
local player_colors = require 'resources.player_colors'
|
2018-08-07 11:33:46 +01:00
|
|
|
|
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_created,
|
|
|
|
function(event)
|
2018-09-23 11:46:58 +01:00
|
|
|
local player = Game.get_player_by_index(event.player_index)
|
2018-08-07 11:33:46 +01:00
|
|
|
if not player or not player.valid then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local color_data = player_colors[player.name]
|
|
|
|
if not color_data then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
player.color = color_data.color
|
|
|
|
player.chat_color = color_data.chat_color or color_data.color
|
|
|
|
end
|
2018-11-10 21:43:11 -05:00
|
|
|
)
|