mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-01-01 05:01:40 +09:00
Merge pull request #180 from bbassie/feature/tag-color
Add command /tag-color
This commit is contained in:
15
config/expcore/command_color_parse.lua
Normal file
15
config/expcore/command_color_parse.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
--- This will make commands only work when a valid color from the presets has been selected
|
||||||
|
-- @config Commands-Color-Parse
|
||||||
|
|
||||||
|
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||||
|
local Colours = require 'utils.color_presets' --- @dep utils.color_presets
|
||||||
|
|
||||||
|
Commands.add_parse('color',function(input, _, reject)
|
||||||
|
if not input then return end
|
||||||
|
local color = Colours[input]
|
||||||
|
if not color then
|
||||||
|
return reject{'expcore-commands.reject-color'}
|
||||||
|
else
|
||||||
|
return input
|
||||||
|
end
|
||||||
|
end)
|
||||||
@@ -153,6 +153,7 @@ Roles.new_role('Supporter','Sup')
|
|||||||
:set_flag('is_spectator')
|
:set_flag('is_spectator')
|
||||||
:set_parent('Veteran')
|
:set_parent('Veteran')
|
||||||
:allow{
|
:allow{
|
||||||
|
'command/tag-color',
|
||||||
'command/jail',
|
'command/jail',
|
||||||
'command/unjail',
|
'command/unjail',
|
||||||
'command/join-message'
|
'command/join-message'
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ UsesServerUps-value-tooltip=Change by using /server-ups
|
|||||||
Tag=Player Tag
|
Tag=Player Tag
|
||||||
Tag-tooltip=The tag shown after your name
|
Tag-tooltip=The tag shown after your name
|
||||||
Tag-value-tooltip=Change by using /tag
|
Tag-value-tooltip=Change by using /tag
|
||||||
|
TagColor=Player Tag color
|
||||||
|
TagColor-tooltip=The color of the tag shown after your name
|
||||||
|
TagColor-value-tooltip=Change by using /tag-color
|
||||||
Bonus=Player Bonus
|
Bonus=Player Bonus
|
||||||
Bonus-tooltip=The bonus given to your character
|
Bonus-tooltip=The bonus given to your character
|
||||||
Bonus-value-tooltip=Change by using /bonus
|
Bonus-value-tooltip=Change by using /bonus
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ reject-player-online=Player is offline.
|
|||||||
reject-player-alive=Player is dead.
|
reject-player-alive=Player is dead.
|
||||||
reject-force=Invalid Force Name.
|
reject-force=Invalid Force Name.
|
||||||
reject-surface=Invalid Surface Name.
|
reject-surface=Invalid Surface Name.
|
||||||
|
reject-color=Invalid Color Name.
|
||||||
invalid-inputs=Invalid Input, /__1__ __2__
|
invalid-inputs=Invalid Input, /__1__ __2__
|
||||||
invalid-param=Invalid Param "__1__"; __2__
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
command-help=__1__ - __2__
|
command-help=__1__ - __2__
|
||||||
|
|||||||
@@ -7,22 +7,43 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
|
|||||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||||
require 'config.expcore.command_general_parse'
|
require 'config.expcore.command_general_parse'
|
||||||
require 'config.expcore.command_role_parse'
|
require 'config.expcore.command_role_parse'
|
||||||
|
require 'config.expcore.command_color_parse'
|
||||||
|
|
||||||
--- Stores the tag for a player
|
--- Stores the tag for a player
|
||||||
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
local PlayerTags = PlayerData.Settings:combine('Tag')
|
local PlayerTags = PlayerData.Settings:combine('Tag')
|
||||||
|
local PlayerTagColors = PlayerData.Settings:combine('TagColor')
|
||||||
PlayerTags:set_metadata{
|
PlayerTags:set_metadata{
|
||||||
permission = 'command/tag'
|
permission = 'command/tag'
|
||||||
}
|
}
|
||||||
|
PlayerTagColors:set_metadata{
|
||||||
|
permission = 'command/tag-color'
|
||||||
|
}
|
||||||
|
|
||||||
|
local set_tag = function (player, tag, color)
|
||||||
|
if tag == nil or tag == '' then
|
||||||
|
player.tag = ''
|
||||||
|
elseif color then
|
||||||
|
player.tag = '- [color='.. color ..']'..tag..'[/color]'
|
||||||
|
else
|
||||||
|
player.tag = '- '..tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- When your tag is updated then apply the changes
|
--- When your tag is updated then apply the changes
|
||||||
PlayerTags:on_update(function(player_name, player_tag)
|
PlayerTags:on_update(function(player_name, player_tag)
|
||||||
local player = game.players[player_name]
|
local player = game.players[player_name]
|
||||||
if player_tag == nil or player_tag == '' then
|
local player_tag_color = PlayerTagColors:get(player)
|
||||||
player.tag = ''
|
|
||||||
else
|
set_tag(player, player_tag, player_tag_color)
|
||||||
player.tag = '- '..player_tag
|
end)
|
||||||
end
|
|
||||||
|
--- When your tag color is updated then apply the changes
|
||||||
|
PlayerTagColors:on_update(function(player_name, player_tag_color)
|
||||||
|
local player = game.players[player_name]
|
||||||
|
local player_tag = PlayerTags:get(player)
|
||||||
|
|
||||||
|
set_tag(player, player_tag, player_tag_color)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Sets your player tag.
|
--- Sets your player tag.
|
||||||
@@ -35,6 +56,16 @@ Commands.new_command('tag', 'Sets your player tag.')
|
|||||||
PlayerTags:set(player, tag)
|
PlayerTags:set(player, tag)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--- Sets your player tag color.
|
||||||
|
-- @command tag
|
||||||
|
-- @tparam string color name.
|
||||||
|
Commands.new_command('tag-color', 'Sets your player tag color.')
|
||||||
|
:add_param('color', false, 'color')
|
||||||
|
:enable_auto_concat()
|
||||||
|
:register(function(player, color)
|
||||||
|
PlayerTagColors:set(player, color)
|
||||||
|
end)
|
||||||
|
|
||||||
--- Clears your tag. Or another player if you are admin.
|
--- Clears your tag. Or another player if you are admin.
|
||||||
-- @command tag-clear
|
-- @command tag-clear
|
||||||
-- @tparam[opt=self] LuaPlayer player the player to remove the tag from, nil will apply to self
|
-- @tparam[opt=self] LuaPlayer player the player to remove the tag from, nil will apply to self
|
||||||
|
|||||||
Reference in New Issue
Block a user