From 48139c5877ea6a79b9a8af4926d038434e4e29ad Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Mon, 8 Aug 2016 23:25:31 +0200 Subject: [PATCH] Added /f promote and removed faction_user requirement --- chatcommands.lua | 22 +++++++++++++++++++--- factions.lua | 10 ++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index 471fbb1..d861bd7 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -143,9 +143,9 @@ init_commands = function() minetest.register_chatcommand("f", { - params = " text", - description = "send message to a specific faction", - privs = { faction_user=true }, + params = " parameters", + description = "Factions commands. Type /f help for available commands.", + privs = { interact=true}, func = factions_chat.cmdhandler, } ) @@ -470,6 +470,22 @@ factions.register_command("spawn", { end }) +factions.register_command("promote", { + description = "Promotes a player to a rank", + format = {"player", "string"}, + faction_permissions = {"promote"}, + on_success = function(player, faction, pos, chunkpos, args) + local rank = args.strings[1] + if faction.ranks[rank] then + faction:promote(args.players[1], rank) + return true + else + send_error(player, "The specified rank does not exist.") + return false + end + end +}) + factions.register_command("power", { description = "Display your faction's power", on_success = function(player, faction, pos, chunkpos, args) diff --git a/factions.lua b/factions.lua index 17385b1..0807f58 100644 --- a/factions.lua +++ b/factions.lua @@ -50,7 +50,7 @@ function factions.Faction:new(faction) faction = { power = 0., players = {}, - ranks = {["leader"] = {"disband", "claim", "playerslist", "build", "description", "ranks", "spawn", "banner"}, + ranks = {["leader"] = {"disband", "claim", "playerslist", "build", "description", "ranks", "spawn", "banner", "promote"}, ["moderator"] = {"claim", "playerslist", "build", "spawn"}, ["member"] = {"build"} }, @@ -227,11 +227,14 @@ function factions.Faction.delete_rank(self, rank, newrank) self:on_delete_rank(rank, newrank) factions.save() end - function factions.Faction.set_banner(self, newbanner) self.banner = newbanner self:on_new_banner() end +function factions.Faction.promote(self, member, rank) + self.players[member] = rank + self:on_promote(member) +end -------------------------- -- callbacks for events -- @@ -283,6 +286,9 @@ end function factions.Faction.on_new_banner(self) --TODO: implement end +function factions.Faction.on_promote(self, member) + --TODO: implement +end --??????????????