mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-02-07 13:31:54 +02:00
Use locale for new rank system
This commit is contained in:
parent
d6a44388e5
commit
52a0622995
@ -84,21 +84,26 @@ local function regular(args)
|
|||||||
|
|
||||||
if add_remove == 'add' then
|
if add_remove == 'add' then
|
||||||
if Rank.less_than(name, Ranks.guest) then
|
if Rank.less_than(name, Ranks.guest) then
|
||||||
Game.player_print('Cannot promote someone on probation to regular. Instead remove their probation and then promote them.', Color.red)
|
-- Cannot promote someone on probation to regular. You must remove them from probation and then promote them.
|
||||||
|
Game.player_print({'admin_commands.regular_add_fail_probation'}, Color.red)
|
||||||
end
|
end
|
||||||
local success, rank = Rank.increase_player_rank_to(name, Ranks.regular)
|
local success, rank = Rank.increase_player_rank_to(name, Ranks.regular)
|
||||||
if success then
|
if success then
|
||||||
game.print(format('%s promoted %s to %s.', Utils.get_actor(), name, rank), Color.yellow)
|
-- __1__ promoted __2__ to __3__.
|
||||||
|
game.print({'admin_commands.regular_add_success', Utils.get_actor(), name, rank}, Color.yellow)
|
||||||
else
|
else
|
||||||
Game.player_print(format('%s is already rank %s.', name, rank), Color.red)
|
-- __1__ is already rank __2__.
|
||||||
|
Game.player_print({'admin_commands.regular_add_fail', name, rank}, Color.red)
|
||||||
end
|
end
|
||||||
elseif add_remove == 'remove' then
|
elseif add_remove == 'remove' then
|
||||||
if Rank.equal(name, Ranks.regular) then
|
if Rank.equal(name, Ranks.regular) then
|
||||||
local new_rank = Rank.decrease_player_rank(name)
|
local new_rank = Rank.decrease_player_rank(name)
|
||||||
game.print(format('%s demoted %s to %s.', Utils.get_actor(), name, new_rank), Color.yellow)
|
-- __1__ demoted __2__ to __3__.
|
||||||
|
game.print({'admin_commands.regular_remove_success', Utils.get_actor(), name, new_rank}, Color.yellow)
|
||||||
else
|
else
|
||||||
local rank_name = Rank.get_player_rank_name(name)
|
local rank_name = Rank.get_player_rank_name(name)
|
||||||
Game.player_print(format('%s is rank %s, their regular status cannot be removed.', name, rank_name), Color.red)
|
-- __1__ is rank __2__ their regular status cannot be removed.
|
||||||
|
Game.player_print({'admin_commands.regular_remove_fail', name, rank_name}, Color.red)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -31,9 +31,8 @@ local sorted_ranks = {}
|
|||||||
local rank_to_index = {}
|
local rank_to_index = {}
|
||||||
|
|
||||||
for k, v in pairs(Ranks) do
|
for k, v in pairs(Ranks) do
|
||||||
rank_name_lookup[v] = k
|
rank_name_lookup[v] = {'ranks.' .. k}
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(Ranks) do
|
for k, v in pairs(Ranks) do
|
||||||
sorted_ranks[#sorted_ranks + 1] = v
|
sorted_ranks[#sorted_ranks + 1] = v
|
||||||
end
|
end
|
||||||
@ -258,7 +257,7 @@ function Public.increase_player_rank(player_name)
|
|||||||
|
|
||||||
local new_rank_name = rank_name_lookup[new_rank]
|
local new_rank_name = rank_name_lookup[new_rank]
|
||||||
if new_rank_name then
|
if new_rank_name then
|
||||||
player_ranks[player_name] = (new_rank)
|
player_ranks[player_name] = new_rank
|
||||||
return new_rank_name
|
return new_rank_name
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
@ -291,7 +290,7 @@ function Public.decrease_player_rank(player_name)
|
|||||||
|
|
||||||
local new_rank_name = rank_name_lookup[new_rank]
|
local new_rank_name = rank_name_lookup[new_rank]
|
||||||
if new_rank_name then
|
if new_rank_name then
|
||||||
player_ranks[player_name] = (new_rank)
|
player_ranks[player_name] = new_rank
|
||||||
return new_rank_name
|
return new_rank_name
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
|
@ -242,7 +242,7 @@ local function print_player_info(args, player)
|
|||||||
'Name: ' .. name,
|
'Name: ' .. name,
|
||||||
target.connected and 'Online: yes' or 'Online: no',
|
target.connected and 'Online: yes' or 'Online: no',
|
||||||
'Index: ' .. target.index,
|
'Index: ' .. target.index,
|
||||||
'Rank: ' .. Rank.get_player_rank_name(name),
|
--'Rank: ' .. Rank.get_player_rank_name(name),
|
||||||
Donator.is_donator(target.name) and 'Donator: yes' or 'Donator: no',
|
Donator.is_donator(target.name) and 'Donator: yes' or 'Donator: no',
|
||||||
'Time played: ' .. Utils.format_time(target.online_time),
|
'Time played: ' .. Utils.format_time(target.online_time),
|
||||||
'AFK time: ' .. Utils.format_time(target.afk_time or 0),
|
'AFK time: ' .. Utils.format_time(target.afk_time or 0),
|
||||||
|
17
locale/en/redmew.cfg
Normal file
17
locale/en/redmew.cfg
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[ranks]
|
||||||
|
probation=Probation
|
||||||
|
guest=Guest
|
||||||
|
auto_trusted=Auto Trusted
|
||||||
|
regular=Regular
|
||||||
|
admin=Admin
|
||||||
|
donator=Donator
|
||||||
|
donator_abbreviation=D
|
||||||
|
|
||||||
|
[admin_commands]
|
||||||
|
regular_add_success=__1__ promoted __2__ to __3__.
|
||||||
|
regular_add_fail=__1__ is already rank __2__.
|
||||||
|
regular_add_fail_probation=Cannot promote someone on probation to regular. You must remove them from probation and then promote them.
|
||||||
|
regular_remove_success=__1__ demoted __2__ to __3__.
|
||||||
|
regular_remove_fail=__1__ is rank __2__ their regular status cannot be removed.
|
||||||
|
|
||||||
|
[redmew_commands]
|
@ -32,7 +32,7 @@ function Module.distance(pos1, pos2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Takes msg and prints it to all players except provided player
|
--- Takes msg and prints it to all players except provided player
|
||||||
-- @param msg <string> The message to print
|
-- @param msg <string|table> table if locale is used
|
||||||
-- @param player <LuaPlayer> the player not to send the message to
|
-- @param player <LuaPlayer> the player not to send the message to
|
||||||
-- @param color <table> the color to use for the message, defaults to white
|
-- @param color <table> the color to use for the message, defaults to white
|
||||||
function Module.print_except(msg, player, color)
|
function Module.print_except(msg, player, color)
|
||||||
@ -48,8 +48,8 @@ function Module.print_except(msg, player, color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Prints a message to all online admins
|
--- Prints a message to all online admins
|
||||||
--@param msg <string> The message to print
|
-- @param msg <string|table> table if locale is used
|
||||||
--@param source <LuaPlayer|string|nil> string must be the name of a player, nil for server.
|
-- @param source <LuaPlayer|string|nil> string must be the name of a player, nil for server.
|
||||||
function Module.print_admins(msg, source)
|
function Module.print_admins(msg, source)
|
||||||
local source_name
|
local source_name
|
||||||
local chat_color
|
local chat_color
|
||||||
|
@ -64,7 +64,7 @@ function Game.get_player_from_any(obj)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Prints to player or console.
|
--- Prints to player or console.
|
||||||
-- @param str <string>
|
-- @param str <string|table> table if locale is used
|
||||||
-- @param color <table> defaults to white
|
-- @param color <table> defaults to white
|
||||||
function Game.player_print(str, color)
|
function Game.player_print(str, color)
|
||||||
color = color or Color.white
|
color = color or Color.white
|
||||||
|
Loading…
x
Reference in New Issue
Block a user