From ce8fec854fca76c2ce41ff1f142ad263a47da927 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Sun, 28 Aug 2016 11:37:14 +0200 Subject: [PATCH 1/6] Added /f resetpower --- chatcommands.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chatcommands.lua b/chatcommands.lua index 8f5fc53..3256990 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -603,6 +603,17 @@ factions.register_command("setadmin", { end }) +factions.register_commad("resetpower", { + description = "Reset a faction's power", + infaction = false, + global_privileges = {"faction_admin"}, + format = {"faction"}, + on_success = function(player, faction, pos, parcelpos, args) + args.factionsp[1].power = 0 + return true + end +}) + ------------------------------------------------------------------------------- -- name: cmdhandler(playername,parameter) -- From 853bf882102772f3b2e905c493d866f1f75b7682 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Sun, 28 Aug 2016 11:55:16 +0200 Subject: [PATCH 2/6] Added /f obliterate and /f getspawn --- chatcommands.lua | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index 3256990..817b61c 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -603,17 +603,46 @@ factions.register_command("setadmin", { end }) -factions.register_commad("resetpower", { +factions.register_command("resetpower", { description = "Reset a faction's power", infaction = false, global_privileges = {"faction_admin"}, format = {"faction"}, on_success = function(player, faction, pos, parcelpos, args) - args.factionsp[1].power = 0 + args.factions[1].power = 0 return true end }) + +factions.register_command("obliterate", { + description = "Remove all factions", + infaction = false, + global_privileges = {"faction_admin"}, + on_success = function(player, faction, pos, parcelpos, args) + for _, f in pairs(factions.factions) do + f:disband("obliterated") + end + end +}) + +factions.register_command("getspawn", { + description = "Get a faction's spawn", + infaction = false, + global_privileges = {"faction_admin"}, + format = {"faction"}, + on_success = function(player, faction, pos, parcelpos, args) + local spawn = args.factions[1].spawn + if spawn then + minetest.chat_send_player(player, spawn.x..","..spawn.y..","..spawn.z) + return true + else + send_error(player, "Faction has no spawn set.") + return false + end + end +}) + ------------------------------------------------------------------------------- -- name: cmdhandler(playername,parameter) -- From 71d95c3ad819db3e876af9ccc1ad99e275814a14 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Sun, 28 Aug 2016 11:59:51 +0200 Subject: [PATCH 3/6] Added /f whoin --- chatcommands.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chatcommands.lua b/chatcommands.lua index 817b61c..55d725a 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -623,6 +623,7 @@ factions.register_command("obliterate", { for _, f in pairs(factions.factions) do f:disband("obliterated") end + return true end }) @@ -643,6 +644,21 @@ factions.register_command("getspawn", { end }) +factions.register_command("whoin", { + description = "Get all members of a faction.", + infaction = false, + global_privileges = {"faction_admin"}, + format = {"faction"}, + on_success = function(player, faction, pos, parcelpos, args) + local msg = {} + for player, _ in pairs(args.factions[1].players) do + table.insert(msg, player) + end + minetest.chat_send_player(player, table.concat(msg, ", ")) + return true + end +}) + ------------------------------------------------------------------------------- -- name: cmdhandler(playername,parameter) -- From 79e270c38dacc2ae2d4b4a4109da945bab40883d Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Sun, 28 Aug 2016 12:03:12 +0200 Subject: [PATCH 4/6] Added /f stats --- chatcommands.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chatcommands.lua b/chatcommands.lua index 55d725a..8d0563b 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -659,6 +659,18 @@ factions.register_command("whoin", { end }) +factions.register_command("stats", { + description = "Get stats of a faction.", + infaction = false, + global_privileges = {"faction_admin"}, + format = {"faction"}, + on_success = function(player, faction, pos, parcelpos, args) + local f = args.factions[1] + minetest.chat_send_player(player, "Power: "..f.power.."/"..f.maxpower - f.usedpower.."/"..f.maxpower) + return true + end +}) + ------------------------------------------------------------------------------- -- name: cmdhandler(playername,parameter) -- From 1e1cb6d65f14d5b7e55ff1f0d0581ed56850c657 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Sun, 28 Aug 2016 12:07:44 +0200 Subject: [PATCH 5/6] Fixed /f spawn --- chatcommands.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index 8d0563b..0b10ad2 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -462,8 +462,10 @@ factions.register_command("help", { factions.register_command("spawn", { description = "Shows your faction's spawn", on_success = function(player, faction, pos, parcelpos, args) - if faction.spawn then - minetest.chat_send_player(player, "Spawn is at ("..table.concat(faction.spawn, ", ")..")") + local spawn = faction.spawn + if spawn then + local spawn = {spawn.x, spawn.y, spawn.z} + minetest.chat_send_player(player, "Spawn is at ("..table.concat(spawn, ", ")..")") return true else minetest.chat_send_player(player, "Your faction has no spawn set.") From 41650823544540eb80a7d6a86390924680024466 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Sun, 28 Aug 2016 12:19:58 +0200 Subject: [PATCH 6/6] Added /f seen --- chatcommands.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/chatcommands.lua b/chatcommands.lua index 0b10ad2..7c19bc9 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -673,6 +673,24 @@ factions.register_command("stats", { end }) +factions.register_command("seen", { + description = "Check the last time a faction had a member logged in", + infaction = false, + global_privileges = {"faction_admin"}, + format = {"faction"}, + on_success = function(player, faction, pos, parcelpos, args) + local lastseen = args.factions[1].last_logon + local now = os.time() + local time = now - lastseen + local minutes = math.floor(time / 60) + local hours = math.floor(minutes / 60) + local days = math.floor(hours / 24) + minetest.chat_send_player(player, "Last seen "..days.." day(s), ".. + hours % 24 .." hour(s), "..minutes % 60 .." minutes, "..time % 60 .." second(s) ago.") + return true + end +}) + ------------------------------------------------------------------------------- -- name: cmdhandler(playername,parameter) --