Update all code styles

This commit is contained in:
Cooldude2606
2024-09-28 01:56:54 +01:00
parent 5e2a62ab27
commit 292c1a1b68
194 changed files with 9817 additions and 9703 deletions

View File

@@ -7,13 +7,13 @@ local config = require("modules.exp_legacy.config.preset_player_colours") --- @d
--- Stores the colour that the player wants
local PlayerData = require("modules.exp_legacy.expcore.player_data") --- @dep expcore.player_data
local PlayerColours = PlayerData.Settings:combine('Colour')
local PlayerColours = PlayerData.Settings:combine("Colour")
PlayerColours:set_metadata{
stringify = function(value)
if not value then return 'None set' end
if not value then return "None set" end
local c = value[1]
return string.format('Red: %d Green: %d Blue: %d', c[1], c[2], c[3])
end
return string.format("Red: %d Green: %d Blue: %d", c[1], c[2], c[3])
end,
}
--- Used to compact player colours to take less space
@@ -22,13 +22,13 @@ local function compact(colour)
return {
floor(colour.r * 255),
floor(colour.g * 255),
floor(colour.b * 255)
floor(colour.b * 255),
}
end
--- Returns a colour that is a bit lighter than the one given
local function lighten(c)
return {r = 255 - (255 - c.r) * 0.5, g = 255 - (255 - c.g) * 0.5, b = 255 - (255 - c.b) * 0.5, a = 255}
return { r = 255 - (255 - c.r) * 0.5, g = 255 - (255 - c.g) * 0.5, b = 255 - (255 - c.b) * 0.5, a = 255 }
end
--- When your data loads apply the players colour, or a random on if none is saved
@@ -36,13 +36,14 @@ PlayerColours:on_load(function(player_name, player_colour)
if not player_colour then
local preset = config.players[player_name]
if preset then
player_colour = {preset, lighten(preset)}
player_colour = { preset, lighten(preset) }
else
local colour_name = 'white'
local colour_name = "white"
while config.disallow[colour_name] do
colour_name = table.get_random_dictionary_entry(Colours, true)
end
player_colour = {Colours[colour_name], lighten(Colours[colour_name])}
player_colour = { Colours[colour_name], lighten(Colours[colour_name]) }
end
end
@@ -53,10 +54,10 @@ end)
--- Save the players color when they use the color command
Event.add(defines.events.on_console_command, function(event)
if event.command ~= 'color' then return end
if event.parameters == '' then return end
if event.command ~= "color" then return end
if event.parameters == "" then return end
if not event.player_index then return end
local player = game.players[event.player_index]
if not player or not player.valid then return end
PlayerColours:set(player, {compact(player.color), compact(player.chat_color)})
end)
PlayerColours:set(player, { compact(player.color), compact(player.chat_color) })
end)