From c703e9ba6d845a2d08556a4cea7a473761ff48fb Mon Sep 17 00:00:00 2001 From: pl608 <78400949+pl608@users.noreply.github.com> Date: Sun, 26 May 2024 17:02:59 -0700 Subject: [PATCH 1/4] Updated playtime mod Now allows checking other players playtime if that player is online. Also added some google translate translations for some of the text I added/updated --- playtime/init.lua | 21 +++++++++++++++------ playtime/locale/playtime.fr.tr | 5 +++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/playtime/init.lua b/playtime/init.lua index 2f5b575..73cf6a9 100644 --- a/playtime/init.lua +++ b/playtime/init.lua @@ -53,15 +53,24 @@ local function format_duration(seconds) end minetest.register_chatcommand("playtime", { - params = "", + params = "", description = S("See your total playtime on this server"), - func = function(name) - if minetest.get_player_by_name(name) then + func = function(name, player_name) + if player_name == '' then + player_name = name + end + if (player_name == '') and minetest.is_singleplayer() then + player_name = 'singleplayer' + end + if not minetest.player_exists(player_name) then + return false, S('You must enter a existing player name!') + end + if minetest.get_player_by_name(player_name) then return true, - C("#63d437", "Total: ")..C("#ffea00", format_duration(playtime.get_total_playtime(name))).."\n".. - C("#63d437", "Current: ")..C("#ffea00", format_duration(playtime.get_session_playtime(name))) + C("#63d437", "Total: ")..C("#ffea00", format_duration(playtime.get_total_playtime(player_name))).."\n".. + C("#63d437", "Current: ")..C("#ffea00", format_duration(playtime.get_session_playtime(player_name))) else - return false, S("You must be connected to run this command!") + return false, S("Player must be online to run this command!") end end, }) diff --git a/playtime/locale/playtime.fr.tr b/playtime/locale/playtime.fr.tr index 2e9c637..d6beada 100644 --- a/playtime/locale/playtime.fr.tr +++ b/playtime/locale/playtime.fr.tr @@ -1,4 +1,5 @@ # textdomain: playtime - +You must enter a existing player name!=Vous devez entrer un nom de joueur existant ! You must be connected to run this command!=Vous devez être connecté pour utiliser cette commande ! -See your total playtime on this server=Voir votre temps de jeu total sur ce serveur \ No newline at end of file +See your total playtime on this server=Voir votre temps de jeu total sur ce serveur +Player must be online to run this command!=Le joueur doit être en ligne pour exécuter cette commande ! \ No newline at end of file From 85c4afe2f8f4e48fc989669f20d1a29de9e26de1 Mon Sep 17 00:00:00 2001 From: pl608 <78400949+pl608@users.noreply.github.com> Date: Wed, 29 May 2024 12:59:38 -0700 Subject: [PATCH 2/4] Update init.lua Made some things look nicer --- playtime/init.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/playtime/init.lua b/playtime/init.lua index 73cf6a9..26cfa37 100644 --- a/playtime/init.lua +++ b/playtime/init.lua @@ -53,23 +53,23 @@ local function format_duration(seconds) end minetest.register_chatcommand("playtime", { - params = "", + params = "[playername]", description = S("See your total playtime on this server"), func = function(name, player_name) - if player_name == '' then + if player_name == "" then player_name = name + if minetest.is_singleplayer() then + player_name = "singleplayer" + end end - if (player_name == '') and minetest.is_singleplayer() then - player_name = 'singleplayer' - end - if not minetest.player_exists(player_name) then - return false, S('You must enter a existing player name!') - end if minetest.get_player_by_name(player_name) then return true, C("#63d437", "Total: ")..C("#ffea00", format_duration(playtime.get_total_playtime(player_name))).."\n".. C("#63d437", "Current: ")..C("#ffea00", format_duration(playtime.get_session_playtime(player_name))) else + if not minetest.player_exists(player_name) then + return false, S("You must enter a existing player name!") + end return false, S("Player must be online to run this command!") end end, From 405d7cc7a2679ac91b6faeb02b634861284ba68d Mon Sep 17 00:00:00 2001 From: pl608 <78400949+pl608@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:41:43 -0700 Subject: [PATCH 3/4] Update init.lua Think I fixed every issue mentioned in the conversation --- playtime/init.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/playtime/init.lua b/playtime/init.lua index 26cfa37..00237a2 100644 --- a/playtime/init.lua +++ b/playtime/init.lua @@ -57,19 +57,13 @@ minetest.register_chatcommand("playtime", { description = S("See your total playtime on this server"), func = function(name, player_name) if player_name == "" then - player_name = name - if minetest.is_singleplayer() then - player_name = "singleplayer" - end + player_name = name or "singleplayer" end if minetest.get_player_by_name(player_name) then return true, C("#63d437", "Total: ")..C("#ffea00", format_duration(playtime.get_total_playtime(player_name))).."\n".. C("#63d437", "Current: ")..C("#ffea00", format_duration(playtime.get_session_playtime(player_name))) else - if not minetest.player_exists(player_name) then - return false, S("You must enter a existing player name!") - end return false, S("Player must be online to run this command!") end end, From f80451a70b4efd921a2cc435bb651ef52a183c73 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Thu, 25 Jul 2024 11:14:37 -0700 Subject: [PATCH 4/4] Update init.lua --- playtime/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playtime/init.lua b/playtime/init.lua index 00237a2..06a573a 100644 --- a/playtime/init.lua +++ b/playtime/init.lua @@ -57,8 +57,9 @@ minetest.register_chatcommand("playtime", { description = S("See your total playtime on this server"), func = function(name, player_name) if player_name == "" then - player_name = name or "singleplayer" - end + player_name = name + end + if minetest.get_player_by_name(player_name) then return true, C("#63d437", "Total: ")..C("#ffea00", format_duration(playtime.get_total_playtime(player_name))).."\n"..