mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-11 14:49:59 +02:00
Sync colors from /color command to the settings
This commit is contained in:
parent
1cd19c69e7
commit
4add981a76
@ -44,6 +44,11 @@ global.config = {
|
||||
time_for_trust = 3 * 60 * 60 * 60, -- 3 hours
|
||||
everyone_is_regular = false
|
||||
},
|
||||
-- allows syncing player colors from and to the server. Disable this if you want to enforce custom colors
|
||||
-- when enabled, /color will also be synced to the player settings
|
||||
player_colors = {
|
||||
enabled = true,
|
||||
},
|
||||
-- saves players' lives if they have a small-plane in their inventory, also adds the small-plane to the market and must therefor be loaded first
|
||||
train_saviour = {
|
||||
enabled = true
|
||||
|
@ -27,7 +27,10 @@ require 'features.server_commands'
|
||||
require 'features.player_create'
|
||||
require 'features.rank_system'
|
||||
require 'features.redmew_settings_sync'
|
||||
require 'features.player_colors'
|
||||
|
||||
if config.player_colors.enabled then
|
||||
require 'features.player_colors'
|
||||
end
|
||||
|
||||
-- Feature modules
|
||||
-- Each can be disabled safely
|
||||
|
@ -2,6 +2,7 @@ local Event = require 'utils.event'
|
||||
local Server = require 'features.server'
|
||||
local Token = require 'utils.token'
|
||||
local Settings = require 'utils.redmew_settings'
|
||||
local Color = require 'resources.color_presets'
|
||||
|
||||
local player_color_name = 'player-color'
|
||||
local player_chat_color_name = 'player-chat-color'
|
||||
@ -69,7 +70,31 @@ local function player_joined_game(event)
|
||||
Server.try_get_data('colors', player.name, color_callback)
|
||||
end
|
||||
|
||||
local function on_command(event)
|
||||
local player_index = event.player_index
|
||||
if not player_index or event.command ~= 'color' then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local color = event.parameters
|
||||
local error = Settings.validate(player_color_name, color)
|
||||
if error then
|
||||
player.print(error, Color.fail)
|
||||
return
|
||||
end
|
||||
|
||||
player.print({'player_colors.gui_setting_reference_message'}, Color.success)
|
||||
Settings.set(player_index, player_color_name, color)
|
||||
Settings.set(player_index, player_chat_color_name, color)
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, player_joined_game)
|
||||
Event.add(Settings.events.on_setting_set, setting_set)
|
||||
Event.add(defines.events.on_console_command, on_command)
|
||||
|
||||
return Public
|
||||
|
@ -82,6 +82,7 @@ color_random=Your color has been changed to: __1__
|
||||
fail_wrong_argument=Only set, reset, and random are accepted arguments
|
||||
player_color_setting_label=Character color
|
||||
player_chat_color_setting_label=Chat color
|
||||
gui_setting_reference_message=Color saved and synchronized to Redmew. You can also use the Redmew Settings (gear icon) to set the character and chat colors.
|
||||
|
||||
[performance]
|
||||
fail_wrong_argument=Scale must be a valid number ranging from 0.05 to 1
|
||||
|
@ -112,8 +112,7 @@ return {
|
||||
|
||||
if input_type == 'string' then
|
||||
local color = Color[input]
|
||||
if color and tonumber(input) == nil then
|
||||
-- we have some numeric keys in there
|
||||
if color then
|
||||
return true, color
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,6 @@ local deprecated_command_alternatives = {
|
||||
|
||||
local notify_on_commands = {
|
||||
['version'] = 'RedMew has a version as well, accessible via /redmew-version',
|
||||
['color'] = 'You can also use the Redmew Settings (gear icon) to set the character and chat colors, this will be synchronized to all Redmew servers',
|
||||
['ban'] = 'In case your forgot: please remember to include a message on how to appeal a ban'
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user