Rename player listing mod to be more consistent
This commit is contained in:
parent
ede6739b9e
commit
3998718eb0
10
mods/player_list/README.txt
Normal file
10
mods/player_list/README.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Player listing mod
|
||||||
|
==================
|
||||||
|
By Kaadmy, for Pixture
|
||||||
|
|
||||||
|
Adds player lists(current/recent/all).
|
||||||
|
|
||||||
|
Use the chatcommand "/plist" to show a player list
|
||||||
|
Change command parameters (none/recent/all) to show different stats
|
||||||
|
|
||||||
|
Source license: LGPLv2.1
|
@ -1,13 +1,13 @@
|
|||||||
--
|
--
|
||||||
-- Playerlist mod
|
-- Player listing mod
|
||||||
-- By Kaadmy, for Pixture
|
-- By Kaadmy, for Pixture
|
||||||
--
|
--
|
||||||
|
|
||||||
playerlist = {}
|
player_list = {}
|
||||||
|
|
||||||
-- current players format:
|
-- current players format:
|
||||||
-- {<playername> = <last connect(if connected, or nil)>}
|
-- {<playername> = <last connect(if connected, or nil)>}
|
||||||
playerlist.players = {}
|
player_list.players = {}
|
||||||
|
|
||||||
local function divmod(f, d)
|
local function divmod(f, d)
|
||||||
return {math.floor(f / d), f % d}
|
return {math.floor(f / d), f % d}
|
||||||
@ -38,13 +38,13 @@ end
|
|||||||
local function on_joinplayer(player)
|
local function on_joinplayer(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
playerlist.players[name] = minetest.get_gametime()
|
player_list.players[name] = minetest.get_gametime()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_leaveplayer(player)
|
local function on_leaveplayer(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
playerlist.players[name] = minetest.get_gametime()
|
player_list.players[name] = minetest.get_gametime()
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(on_joinplayer)
|
minetest.register_on_joinplayer(on_joinplayer)
|
||||||
@ -54,7 +54,7 @@ minetest.register_chatcommand(
|
|||||||
"plist",
|
"plist",
|
||||||
{
|
{
|
||||||
params = "[all|recent]",
|
params = "[all|recent]",
|
||||||
description = "List players that are connected and have connected since the last server restart",
|
description = "List current, recent, or all players since the last server restart",
|
||||||
func = function(player_name, param)
|
func = function(player_name, param)
|
||||||
local time = minetest.get_gametime()
|
local time = minetest.get_gametime()
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ minetest.register_chatcommand(
|
|||||||
end
|
end
|
||||||
|
|
||||||
local player_count = 0
|
local player_count = 0
|
||||||
for name, jointime in pairs(playerlist.players) do
|
for name, jointime in pairs(player_list.players) do
|
||||||
local plyr = minetest.get_player_by_name(name)
|
local plyr = minetest.get_player_by_name(name)
|
||||||
|
|
||||||
if param == "all" then
|
if param == "all" then
|
||||||
@ -79,15 +79,23 @@ minetest.register_chatcommand(
|
|||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name, " " .. name .. ": last seen " .. prettytime(time - jointime) .. " ago")
|
minetest.chat_send_player(player_name, " " .. name .. ": last seen " .. prettytime(time - jointime) .. " ago")
|
||||||
end
|
end
|
||||||
else
|
elseif param == "recent" then
|
||||||
if param == "recent" then
|
if plyr == nil then -- Only show players that were connected but are currently disconnected
|
||||||
if plyr == nil then
|
|
||||||
player_count = player_count + 1
|
player_count = player_count + 1
|
||||||
str = str .. name .. ", "
|
|
||||||
|
if player_count == 1 then
|
||||||
|
str = str .. name
|
||||||
|
else
|
||||||
|
str = str .. ", " .. name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif plyr ~= nil then
|
elseif plyr ~= nil then
|
||||||
player_count = player_count + 1
|
player_count = player_count + 1
|
||||||
str = str .. name .. ", "
|
|
||||||
|
if player_count == 1 then
|
||||||
|
str = str .. name
|
||||||
|
else
|
||||||
|
str = str .. ", " .. name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -102,4 +110,4 @@ minetest.register_chatcommand(
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
default.log("mod:playerlist", "loaded")
|
default.log("mod:player_list", "loaded")
|
@ -1,10 +0,0 @@
|
|||||||
Playerlist mod
|
|
||||||
==================
|
|
||||||
By Kaadmy, for Pixture
|
|
||||||
|
|
||||||
Adds player lists(recent/current).
|
|
||||||
|
|
||||||
Use the chatcommand "/plist" to show current players
|
|
||||||
Change command parameters (recent/all) to show different stats
|
|
||||||
|
|
||||||
Source license: LGPLv2.1
|
|
Loading…
Reference in New Issue
Block a user