2018-08-07 12:33:46 +02:00
|
|
|
local Event = require 'utils.event'
|
2018-09-23 00:25:13 +02:00
|
|
|
local Game = require 'utils.game'
|
2018-11-11 04:43:11 +02:00
|
|
|
local player_colors = require 'resources.player_colors'
|
2018-08-07 12:33:46 +02:00
|
|
|
|
|
|
|
Event.add(
|
|
|
|
defines.events.on_player_created,
|
|
|
|
function(event)
|
2018-09-23 12:46:58 +02:00
|
|
|
local player = Game.get_player_by_index(event.player_index)
|
2018-08-07 12:33:46 +02: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-20 12:46:19 +02:00
|
|
|
)
|