mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-05 15:05:57 +02:00
Translate whois data
This commit is contained in:
parent
97d96dedf3
commit
fdee00dc06
12
config.lua
12
config.lua
@ -283,7 +283,17 @@ global.config = {
|
||||
},
|
||||
-- adds many commands for users and admins alike
|
||||
redmew_commands = {
|
||||
enabled = true
|
||||
enabled = true,
|
||||
whois = {
|
||||
player_data_to_show = {
|
||||
'player-distance-walked',
|
||||
'coins-earned',
|
||||
'coins-spent',
|
||||
'player-deaths',
|
||||
'player-items-crafted',
|
||||
'player-console-chats'
|
||||
}
|
||||
}
|
||||
},
|
||||
-- adds many commands for admins
|
||||
admin_commands = {
|
||||
|
@ -51,7 +51,7 @@ local player_poke_cooldown = {}
|
||||
local player_pokes = {}
|
||||
local player_settings = {}
|
||||
local no_notify_players = {}
|
||||
local prototype_localised_string_cache = {}
|
||||
local prototype_locale_string_cache = {}
|
||||
|
||||
Global.register(
|
||||
{
|
||||
@ -363,15 +363,15 @@ local column_builders = {
|
||||
draw_cell = function(parent, cell_data)
|
||||
local tooltip = {''}
|
||||
for name, count in pairs(cell_data.causes) do
|
||||
if not prototype_localised_string_cache[name] then
|
||||
if not prototype_locale_string_cache[name] then
|
||||
local prototype = game.entity_prototypes[name]
|
||||
if not prototype then
|
||||
prototype = game.item_prototypes[name]
|
||||
end
|
||||
prototype_localised_string_cache[name] = prototype and prototype.localised_name or {name}
|
||||
prototype_locale_string_cache[name] = prototype and prototype.localised_name or {name}
|
||||
end
|
||||
|
||||
insert(tooltip, prototype_localised_string_cache[name])
|
||||
insert(tooltip, prototype_locale_string_cache[name])
|
||||
insert(tooltip, ': ')
|
||||
insert(tooltip, count)
|
||||
insert(tooltip, '\n')
|
||||
|
@ -115,7 +115,7 @@ local function draw_main_frame(center, player)
|
||||
for name, setting in pairs(settings) do
|
||||
local label = setting_grid.add({
|
||||
type = 'label',
|
||||
caption = setting.localised_string,
|
||||
caption = setting.locale_string,
|
||||
})
|
||||
|
||||
local label_style = label.style
|
||||
|
@ -8,6 +8,7 @@ local Server = require 'features.server'
|
||||
local ScoreTracker = require 'utils.score_tracker'
|
||||
local format_number = require 'util'.format_number
|
||||
local pairs = pairs
|
||||
local concat = table.concat
|
||||
local scores_to_show = global.config.score.global_to_show
|
||||
local set_timeout_in_ticks = Schedule.set_timeout_in_ticks
|
||||
local main_frame_name = Gui.uid_name()
|
||||
@ -23,27 +24,18 @@ Global.register(memory, function(tbl) memory = tbl end)
|
||||
|
||||
---Creates a map of score name => {captain, tooltip}
|
||||
local function get_global_score_labels()
|
||||
local metadata = ScoreTracker.get_score_metadata()
|
||||
local scores = {}
|
||||
local scores = ScoreTracker.get_global_scores_with_metadata(scores_to_show)
|
||||
local score_labels = {}
|
||||
|
||||
for index = 1, #scores_to_show do
|
||||
local score_name = scores_to_show[index]
|
||||
local score_metadata = metadata[score_name]
|
||||
if score_metadata then
|
||||
local icon = score_metadata.icon
|
||||
local label_text = ''
|
||||
if icon then
|
||||
label_text = icon .. ' '
|
||||
end
|
||||
|
||||
scores[score_name] = {
|
||||
caption = label_text .. format_number(ScoreTracker.get_for_global(score_name), true),
|
||||
tooltip = score_metadata.localised_string
|
||||
}
|
||||
end
|
||||
for index = 1, #scores do
|
||||
local score_data = scores[index]
|
||||
score_labels[score_data.name] = {
|
||||
caption = concat({score_data.icon, format_number(score_data.value, true)}, ' '),
|
||||
tooltip = score_data.locale_string
|
||||
}
|
||||
end
|
||||
|
||||
return scores
|
||||
return score_labels
|
||||
end
|
||||
|
||||
local do_redraw_score = Token.register(function()
|
||||
|
@ -7,13 +7,9 @@ local Rank = require 'features.rank_system'
|
||||
local Donator = require 'features.donator'
|
||||
local Color = require 'resources.color_presets'
|
||||
local ScoreTracker = require 'utils.score_tracker'
|
||||
local get_for_player = ScoreTracker.get_for_player
|
||||
local coins_spent_name = 'coins-spent'
|
||||
local coins_earned_name = 'coins-earned'
|
||||
local player_deaths_name = 'player-deaths'
|
||||
local player_console_chats_name = 'player-console-chats'
|
||||
local player_items_crafted_name = 'player-items-crafted'
|
||||
local player_distance_walked_name = 'player-distance-walked'
|
||||
local format_number = require 'util'.format_number
|
||||
local player_data_to_show = global.config.redmew_commands.whois.player_data_to_show
|
||||
local print_to_player = Game.player_print
|
||||
local concat = table.concat
|
||||
local tostring = tostring
|
||||
local tonumber = tonumber
|
||||
@ -22,7 +18,7 @@ local floor = math.floor
|
||||
|
||||
--- Informs the actor that there is no target. Acts as a central place where this message can be changed.
|
||||
local function print_no_target(target_name)
|
||||
Game.player_print({'common.fail_no_target', target_name}, Color.fail)
|
||||
print_to_player({'common.fail_no_target', target_name}, Color.fail)
|
||||
end
|
||||
|
||||
--- Kill a player with fish as the cause of death.
|
||||
@ -57,18 +53,18 @@ local function kill(args, player)
|
||||
if player then
|
||||
if not target or target == player then -- player suicide
|
||||
if not do_fish_kill(player, true) then
|
||||
Game.player_print({'redmew_commands.kill_fail_suicide_no_character'})
|
||||
print_to_player({'redmew_commands.kill_fail_suicide_no_character'})
|
||||
end
|
||||
elseif target and player.admin then -- admin killing target
|
||||
if not do_fish_kill(target) then
|
||||
Game.player_print({'redmew_commands.kill_fail_target_no_character'}, target_name)
|
||||
print_to_player({'redmew_commands.kill_fail_target_no_character'}, target_name)
|
||||
end
|
||||
else -- player failing to kill target
|
||||
Game.player_print({'redmew_commands.kill_fail_no_perm'})
|
||||
print_to_player({'redmew_commands.kill_fail_no_perm'})
|
||||
end
|
||||
elseif target then -- server killing target
|
||||
if not do_fish_kill(target) then
|
||||
Game.player_print({'redmew_commands.kill_fail_target_no_character'}, target_name)
|
||||
print_to_player({'redmew_commands.kill_fail_target_no_character'}, target_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -88,11 +84,11 @@ local function afk()
|
||||
time = time .. floor(afk_time / 3600) % 60 .. ' minutes and '
|
||||
end
|
||||
time = time .. floor(v.afk_time / 60) % 60 .. ' seconds.'
|
||||
Game.player_print(v.name .. ' has been afk for' .. time)
|
||||
print_to_player(v.name .. ' has been afk for' .. time)
|
||||
end
|
||||
end
|
||||
if count == 0 then
|
||||
Game.player_print({'redmew_commands.afk_no_afk'})
|
||||
print_to_player({'redmew_commands.afk_no_afk'})
|
||||
end
|
||||
end
|
||||
|
||||
@ -102,7 +98,7 @@ local function zoom(args, player)
|
||||
if zoom_val then
|
||||
player.zoom = zoom_val
|
||||
else
|
||||
Game.player_print({'redmew_commands.zoom_fail'})
|
||||
print_to_player({'redmew_commands.zoom_fail'})
|
||||
end
|
||||
end
|
||||
|
||||
@ -118,7 +114,7 @@ local function find_player(args, player)
|
||||
|
||||
target = target.character
|
||||
if not target or not target.valid then
|
||||
Game.player_print({'redmew_commands.find_player_fail_no_character', target_name})
|
||||
print_to_player({'redmew_commands.find_player_fail_no_character', target_name})
|
||||
return
|
||||
end
|
||||
|
||||
@ -131,7 +127,7 @@ local function show_rail_block(_, player)
|
||||
local show = not vs.show_rail_block_visualisation
|
||||
vs.show_rail_block_visualisation = show
|
||||
|
||||
Game.player_print({'redmew_commands.show_rail_block_success', tostring(show)})
|
||||
print_to_player({'redmew_commands.show_rail_block_success', tostring(show)})
|
||||
end
|
||||
|
||||
--- Provides the time on the server
|
||||
@ -166,7 +162,7 @@ local function list_seeds()
|
||||
|
||||
seeds[#seeds] = nil
|
||||
seeds = concat(seeds)
|
||||
Game.player_print(seeds)
|
||||
print_to_player(seeds)
|
||||
end
|
||||
|
||||
local function print_version()
|
||||
@ -176,45 +172,43 @@ local function print_version()
|
||||
else
|
||||
version_str = {'redmew_commands.print_version_from_source'}
|
||||
end
|
||||
Game.player_print(version_str)
|
||||
print_to_player(version_str)
|
||||
end
|
||||
|
||||
--- Prints information about the target player
|
||||
local function print_player_info(args, player)
|
||||
local target_ident = args.player
|
||||
local target, target_name, index = Utils.validate_player(target_ident)
|
||||
local target, target_name, player_index = Utils.validate_player(target_ident)
|
||||
|
||||
if not target then
|
||||
print_no_target(target_ident)
|
||||
return
|
||||
end
|
||||
|
||||
local info_t = {
|
||||
'redmew_commands.whois_formatter',
|
||||
{'format.1_colon_2', 'Name', target_name},
|
||||
{'format.single_item', target.connected and 'Online: yes' or 'Online: no'},
|
||||
{'format.1_colon_2', 'Index', target.index},
|
||||
{'format.1_colon_2', 'Rank', Rank.get_player_rank_name(target_name)},
|
||||
{'format.single_item', Donator.is_donator(target.name) and 'Donator: yes' or 'Donator: no'},
|
||||
{'format.1_colon_2', 'Time played', Utils.format_time(target.online_time)},
|
||||
{'format.1_colon_2', 'AFK time', Utils.format_time(target.afk_time or 0)},
|
||||
{'format.1_colon_2', 'Force', target.force.name},
|
||||
{'format.1_colon_2', 'Surface', target.surface.name},
|
||||
{'format.1_colon_2', 'Tag', target.tag},
|
||||
{'format.1_colon_2', 'Distance walked', get_for_player(index, player_distance_walked_name)},
|
||||
{'format.1_colon_2', 'Coin earned', get_for_player(index, coins_earned_name)},
|
||||
{'format.1_colon_2', 'Coin spent', get_for_player(index, coins_spent_name)},
|
||||
{'format.1_colon_2', 'Deaths', get_for_player(index, player_deaths_name)},
|
||||
{'format.1_colon_2', 'Crafted items', get_for_player(index, player_items_crafted_name)},
|
||||
{'format.1_colon_2', 'Chat messages', get_for_player(index, player_console_chats_name)}
|
||||
}
|
||||
Game.player_print(info_t)
|
||||
local sep = ': '
|
||||
print_to_player({'', {'common.player_name'}, sep, target_name})
|
||||
print_to_player({'', {'common.connection_status'}, sep, {target.connected and 'common.online' or 'common.offline'}})
|
||||
print_to_player({'', {'common.player_index'}, sep, target.index})
|
||||
print_to_player({'', {'common.player_rank'}, sep, Rank.get_player_rank_name(target_name)})
|
||||
print_to_player({'', {'ranks.donator'}, sep, {Donator.is_donator(target.name) and 'common.yes' or 'common.no'}})
|
||||
print_to_player({'', {'common.time_played'}, sep, Utils.format_time(target.online_time)})
|
||||
print_to_player({'', {'common.afk_time'}, sep, Utils.format_time(target.afk_time or 0)})
|
||||
print_to_player({'', {'common.current_force'}, sep, target.force.name})
|
||||
print_to_player({'', {'common.current_surface'}, sep, target.surface.name})
|
||||
print_to_player({'', {'common.player_tag'}, sep, target.tag})
|
||||
|
||||
local scores = ScoreTracker.get_player_scores_with_metadata(player_index, player_data_to_show)
|
||||
|
||||
for i = 1, #scores do
|
||||
local score_data = scores[i]
|
||||
print_to_player({'', score_data.locale_string, sep, format_number(score_data.value, true)})
|
||||
end
|
||||
|
||||
if (not player or player.admin) and args.inventory then
|
||||
local m_inventory = target.get_inventory(defines.inventory.character_main)
|
||||
m_inventory = m_inventory.get_contents()
|
||||
Game.player_print('Main and hotbar inventories: ')
|
||||
Game.player_print(serpent.line(m_inventory))
|
||||
print_to_player('Main and hotbar inventories: ')
|
||||
print_to_player(serpent.line(m_inventory))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Žádný hráč se jménem __1__ se nenašel
|
||||
warn_no_target=Varování: hráč __1__ nebyl nalezen, ale příkaz bude stále vykonán.
|
||||
|
@ -30,7 +30,6 @@ mention_not_found_plural=__1__ Hráči nebyli nalezeni: __2__
|
||||
mention_not_found_singular=__1__ Hráč nebyl nalezen: __2__
|
||||
|
||||
[redmew_commands]
|
||||
whois_formatter=__1__\n__2__\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__\n__9__\n__10__\n__11__\n__12__\n__13__\n__14__\n__15__\n__16__\n
|
||||
kill_fail_suicide_no_character=Promiňte, ale nemáte postavu, kterou byste zabili.
|
||||
kill_fail_target_no_character=Promiň, ale __1__ nemá postavu, kterou by zabil.
|
||||
kill_fail_no_perm=Nemáte oprávnění použít /kill na ostatních hráčích.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Inger spiller fundet med navn: __1__
|
||||
warn_no_target=Advarsel: spiller __1__ er ikke fundet, men kommandoen bliver stadig udført.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Kein Spieler mit Name __1__ gefunden.
|
||||
warn_no_target=Warnung: Spieler __1__ konnte nicht gefunden werden, der Befehl wird trotzdem ausgeführt.
|
||||
|
@ -5,6 +5,19 @@ fail_no_target=No player found with name: __1__
|
||||
warn_no_target=Warning: player __1__ is not found, but the command will still be executed.
|
||||
close_button=Close
|
||||
server_unavailable=The server is currently unavailable.
|
||||
player_name=Player name
|
||||
connection_status=Connection status
|
||||
online=online
|
||||
offline=offline
|
||||
player_index=Player index
|
||||
player_rank=Player rank
|
||||
yes=yes
|
||||
no=no
|
||||
time_played=Time played
|
||||
afk_time=AFK time
|
||||
current_force=Current force
|
||||
current_surface=Current surface
|
||||
player_tag=Player tag
|
||||
|
||||
[ranks]
|
||||
probation=Probation
|
||||
@ -14,7 +27,3 @@ regular=Regular
|
||||
admin=Admin
|
||||
donator=Donator
|
||||
donator_abbreviation=D
|
||||
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
@ -33,7 +33,6 @@ destroy_success=__1__ destroyed
|
||||
destroy_fail=Nothing found to destroy. (You must have an entity under your cursor when you hit enter)
|
||||
|
||||
[redmew_commands]
|
||||
whois_formatter=__1__\n__2__\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__\n__9__\n__10__\n__11__\n__12__\n__13__\n__14__\n__15__\n__16__\n
|
||||
kill_fail_suicide_no_character=Sorry, you don't have a character to kill.
|
||||
kill_fail_target_no_character=Sorry, __1__ doesn't have a character to kill.
|
||||
kill_fail_no_perm=Sorry you don't have permission to use the kill command on other players.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Pelaajaa ei löydy nimellä __1__
|
||||
warn_no_target=Varoitus: pelaaja __1__ ei löydy, mutta komento on suoritettu.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Non jouer avec le nom: __1__
|
||||
warn_no_target=Attention! Jouer __1__ ne trouvé pas. L'execution de le commandement aller continu.
|
||||
|
@ -23,7 +23,6 @@ mention_not_found_plural=__1__ Joueurs introuvables : __2__
|
||||
mention_not_found_singular=__1__ Joueur introuvable : __2__
|
||||
|
||||
[redmew_commands]
|
||||
whois_formatter=__1__\n__2__\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__\n__9__\n__10__\n__11__\n__12__\n__13__\n__14__\n__15__\n__16__\n
|
||||
kill_fail_suicide_no_character=Désolé, vous n'avez pas de personnage à tuer.
|
||||
kill_fail_target_no_character=Désolé, __1__ n'a pas de caractère à tuer.
|
||||
kill_fail_no_perm=Désolé vous n'avez pas la permission d'utiliser la commande ""tuer"" sur les autres joueurs.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=이름 __1__ 을 가진 플레이어를 찾지 못했습니다.
|
||||
warn_no_target=경고: 이름 __1__ 을 가진 플레이어를 찾지 못했지만, 명령은 실행 될 것입니다.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Ingen spiller funnet med navnet: __1__
|
||||
warn_no_target=Advarsel: spiller __1__ er ikke funnet, men kommando vil fortsatt bli utført.
|
||||
|
@ -30,7 +30,6 @@ mention_not_found_plural=__1__ Spillere ikke funnet: __2__
|
||||
mention_not_found_singular=__1__ Spiller ikke funnet: __2__
|
||||
|
||||
[redmew_commands]
|
||||
whois_formatter=__1__\n__2__\n__3__\n__4__\n__5__\n__6__\n__7__\n__8__\n__9__\n__10__\n__11__\n__12__\n__13__\n__14__\n__15__\n__16__\n
|
||||
kill_fail_suicide_no_character=Beklager, du har ikke et character å drepe.
|
||||
kill_fail_target_no_character=Sorry, __1__ har ikke en character å drepe.
|
||||
kill_fail_no_perm=Beklager at du ikke har tillatelse til å bruke kill kommandoen på andre spillere.
|
||||
|
@ -1,7 +1,3 @@
|
||||
[format]
|
||||
1_colon_2=__1__: __2__
|
||||
single_item=__1__
|
||||
|
||||
[common]
|
||||
fail_no_target=Nenhum jogador encontrado com nome: __1__
|
||||
warn_no_target=Aviso: o jogador __1__ não foi encontrado, mas o comando ainda será executado.
|
||||
|
@ -1,5 +1,6 @@
|
||||
local Global = require 'utils.global'
|
||||
local Color = require 'resources.color_presets'
|
||||
local print = print
|
||||
|
||||
local Game = {}
|
||||
|
||||
@ -31,8 +32,9 @@ end
|
||||
-- @param color <table> defaults to white
|
||||
function Game.player_print(msg, color)
|
||||
color = color or Color.white
|
||||
if game.player then
|
||||
game.player.print(msg, color)
|
||||
local player = game.player
|
||||
if player then
|
||||
player.print(msg, color)
|
||||
else
|
||||
print(msg)
|
||||
end
|
||||
|
@ -82,7 +82,7 @@ function Public.register(name, setting_type, default, localisation_key)
|
||||
type = setting_type,
|
||||
default = default,
|
||||
data_transformation = data_transformation,
|
||||
localised_string = localisation_key and {localisation_key} or name,
|
||||
locale_string = localisation_key and {localisation_key} or name,
|
||||
}
|
||||
|
||||
settings[name] = setting
|
||||
|
@ -39,9 +39,9 @@ local on_global_score_changed = Public.events.on_global_score_changed
|
||||
--- This function must be called in the control stage, i.e. not inside an event.
|
||||
---
|
||||
---@param name string
|
||||
---@param localisation_string table
|
||||
---@param locale_string table
|
||||
---@param icon string
|
||||
function Public.register(name, localisation_string, icon)
|
||||
function Public.register(name, locale_string, icon)
|
||||
if _LIFECYCLE ~= _STAGE.control then
|
||||
error(format('You can only register score types in the control stage, i.e. not inside events. Tried setting "%s".', name), 2)
|
||||
end
|
||||
@ -53,7 +53,7 @@ function Public.register(name, localisation_string, icon)
|
||||
local score = {
|
||||
name = name,
|
||||
icon = icon,
|
||||
localised_string = localisation_string
|
||||
locale_string = locale_string
|
||||
}
|
||||
|
||||
score_metadata[name] = score
|
||||
@ -147,6 +147,56 @@ function Public.get_for_global(score_name)
|
||||
return memory_global[score_name] or 0
|
||||
end
|
||||
|
||||
---Returns all metadata merged with the values for this player for the given score names.
|
||||
---
|
||||
---@param player_index number
|
||||
---@param score_names table
|
||||
function Public.get_player_scores_with_metadata(player_index, score_names)
|
||||
local scores = {}
|
||||
local size = 0
|
||||
for i = 1, #score_names do
|
||||
local score_name = score_names[i]
|
||||
local metadata = score_metadata[score_name]
|
||||
if metadata then
|
||||
local player_scores = memory_players[player_index]
|
||||
if player_scores then
|
||||
size = size + 1
|
||||
scores[size] = {
|
||||
name = metadata.name,
|
||||
locale_string = metadata.locale_string,
|
||||
icon = metadata.icon,
|
||||
value = player_scores[score_name] or 0
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return scores
|
||||
end
|
||||
|
||||
---Returns all metadata merged with the values of the global scores for the given score names.
|
||||
---
|
||||
---@param score_names table
|
||||
function Public.get_global_scores_with_metadata(score_names)
|
||||
local scores = {}
|
||||
local size = 0
|
||||
for i = 1, #score_names do
|
||||
local score_name = score_names[i]
|
||||
local metadata = score_metadata[score_name]
|
||||
if metadata then
|
||||
size = size + 1
|
||||
scores[size] = {
|
||||
name = metadata.name,
|
||||
locale_string = metadata.locale_string,
|
||||
icon = metadata.icon,
|
||||
value = memory_global[score_name] or 0
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
return scores
|
||||
end
|
||||
|
||||
---Returns the full score metadata, note that this is a reference, do not modify
|
||||
---this data unless you know what you're doing!
|
||||
function Public.get_score_metadata()
|
||||
|
Loading…
x
Reference in New Issue
Block a user