Skip to content

Commit

Permalink
Allow checking the playtime of other players (#63)
Browse files Browse the repository at this point in the history
* 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

* Update init.lua

Made some things look nicer

* Update init.lua

Think I fixed every issue mentioned in the conversation

* Update init.lua

---------

Co-authored-by: LoneWolfHT <[email protected]>
  • Loading branch information
pl608 and LoneWolfHT authored Jul 25, 2024
1 parent 4bc5153 commit ca4614a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 10 additions & 6 deletions playtime/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ 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)
if minetest.get_player_by_name(name) then
func = function(name, player_name)
if player_name == "" then
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(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,
})
5 changes: 3 additions & 2 deletions playtime/locale/playtime.fr.tr
Original file line number Diff line number Diff line change
@@ -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
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 !

0 comments on commit ca4614a

Please sign in to comment.