mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-22 07:13:50 +01:00
Add the member list in /faction info
This commit is contained in:
parent
d9844f27e4
commit
8e4aa0db51
37
init.lua
37
init.lua
@ -26,7 +26,7 @@ end
|
|||||||
-- Data manipulation
|
-- Data manipulation
|
||||||
function factions.get_player_faction(name)
|
function factions.get_player_faction(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
|
||||||
-- Look in faction objects if we can't do the shortcut
|
-- Look in faction objects if we can't do the shortcut
|
||||||
if player == nil then
|
if player == nil then
|
||||||
for fname, fact in pairs(facts) do
|
for fname, fact in pairs(facts) do
|
||||||
@ -35,7 +35,7 @@ function factions.get_player_faction(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
-- Player is online, we can take a shortcut using the player object
|
-- Player is online, we can take a shortcut using the player object
|
||||||
-- In the future, we can always do this; see https://github.com/minetest/minetest/issues/6193
|
-- In the future, we can always do this; see https://github.com/minetest/minetest/issues/6193
|
||||||
else
|
else
|
||||||
@ -160,18 +160,29 @@ local function handle_command(name, param)
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
elseif action == "info" then
|
elseif action == "info" then
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
faction_name = factions.get_player_faction(name)
|
faction_name = factions.get_player_faction(name)
|
||||||
end
|
minetest.chat_send_player(name, S("No faction were given, returning information about your oldest faction (e.g. the oldest created faction you are in)"))
|
||||||
if faction_name == nil then
|
end
|
||||||
minetest.chat_send_player(name, S("Missing faction name"))
|
if faction_name == nil then
|
||||||
else
|
minetest.chat_send_player(name, S("Missing faction name"))
|
||||||
minetest.chat_send_player(name, S("Owner: @1", factions.get_owner(faction_name)))
|
elseif facts[faction_name] == nil then
|
||||||
if factions.get_owner(faction_name) == name then
|
minetest.chat_send_player(name, S("This faction is not registered"))
|
||||||
minetest.chat_send_player(name, S("Password: @1", factions.get_password(faction_name)))
|
else
|
||||||
|
local fmembers = ""
|
||||||
|
for play,_ in pairs(facts[faction_name].members) do
|
||||||
|
if fmembers == "" then
|
||||||
|
fmembers = play
|
||||||
|
else
|
||||||
|
fmembers = fmembers..", "..play
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
minetest.chat_send_player(name, S("Name: @1\nOwner: @2\nMembers: #@3", faction_name, factions.get_owner(faction_name), fmembers))
|
||||||
|
if factions.get_owner(faction_name) == name then
|
||||||
|
minetest.chat_send_player(name, S("Password: @1", factions.get_password(faction_name)))
|
||||||
|
end
|
||||||
|
end
|
||||||
elseif action == "join" then
|
elseif action == "join" then
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
@ -264,7 +275,7 @@ minetest.register_chatcommand("factions", {
|
|||||||
.."disband: "..S("Disband your faction").."\n"
|
.."disband: "..S("Disband your faction").."\n"
|
||||||
.."passwd <password>: "..S("Change your faction's password").."\n"
|
.."passwd <password>: "..S("Change your faction's password").."\n"
|
||||||
.."chown <player>:"..S("Transfer ownership of your faction").."\n",
|
.."chown <player>:"..S("Transfer ownership of your faction").."\n",
|
||||||
|
|
||||||
description = "",
|
description = "",
|
||||||
privs = {},
|
privs = {},
|
||||||
func = handle_command
|
func = handle_command
|
||||||
|
Loading…
Reference in New Issue
Block a user