Added Player Auto Color

This commit is contained in:
Cooldude2606
2019-04-18 23:20:19 +01:00
parent 652fb42ec9
commit 6af7bc1074
7 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
local Colours = require 'resources.colour_presets'
local Game = require 'utils.game'
local Event = require 'utils.events'
local config = require 'config.preset_player_colours'
local Global = require 'utils.global'
require 'utils.table'
Global.reigster(config,function(tbl)
config = tbl
end)
local white = Colours.white
local black = Colours.black
Event.add(defines.events.on_player_created,function(event)
local color = 'white'
if config.players[player.name] then
color = config.players[player.name]
else
while not config.disallow[color] do
color = table.get_random_dictionary_entry(Colours,true)
end
color = Colours[color]
end
color = {r=color.r/255,g=color.g/255,b=color.b/255,a=0.5}
player.color = color
player.chat_color = color
end)