From 3445066913114662a2ac3172804027a7922c30e9 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Mon, 8 Aug 2016 21:09:10 +0200 Subject: [PATCH] Added banners support --- chatcommands.lua | 24 ++++++++++++++++++++++++ factions.lua | 12 ++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index ff776d0..471fbb1 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -453,6 +453,7 @@ factions.register_command("help", { infaction = false, on_success = function(player, faction, pos, chunkpos, args) factions_chat.show_help(player) + return true end }) @@ -464,10 +465,33 @@ factions.register_command("spawn", { return true else minetest.chat_send_player(player, "Your faction has no spawn set.") + return false end end }) +factions.register_command("power", { + description = "Display your faction's power", + on_success = function(player, faction, pos, chunkpos, args) + minetest.chat_send_player(player, "Power: "..faction.power) + return true + end +}) + +factions.register_command("setbanner", { + description = "Sets the banner you're on as the faction's banner.", + faction_permissions = {"banner"}, + on_success = function(player, faction, pos, chunkpos, args) + local meta = minetest.get_meta({x = pos.x, y = pos.y - 1, z = pos.z}) + local banner = meta:get_string("banner") + if not banner then + minetest.chat_send_player(player, "No banner found.") + return false + end + faction:set_banner(banner) + end +}) + factions.register_command("convert", { description = "Load factions in the old format", infaction = false, diff --git a/factions.lua b/factions.lua index 07c93f4..17385b1 100644 --- a/factions.lua +++ b/factions.lua @@ -28,7 +28,7 @@ factions.players = {} factions.factions = {} --- settings factions.lower_laimable_height = -512 -factions.power_per_chunk = 0. +factions.power_per_chunk = .5 --------------------- --! @brief returns whether a faction can be created or not (allows for implementation of blacklists and the like) @@ -50,7 +50,7 @@ function factions.Faction:new(faction) faction = { power = 0., players = {}, - ranks = {["leader"] = {"disband", "claim", "playerslist", "build", "description", "ranks", "spawn"}, + ranks = {["leader"] = {"disband", "claim", "playerslist", "build", "description", "ranks", "spawn", "banner"}, ["moderator"] = {"claim", "playerslist", "build", "spawn"}, ["member"] = {"build"} }, @@ -228,6 +228,11 @@ function factions.Faction.delete_rank(self, rank, newrank) factions.save() end +function factions.Faction.set_banner(self, newbanner) + self.banner = newbanner + self:on_new_banner() +end + -------------------------- -- callbacks for events -- function factions.Faction.on_create(self) --! @brief called when the faction is added to the global faction list @@ -275,6 +280,9 @@ end function factions.Faction.on_delete_rank(self, rank, newrank) --TODO: implement end +function factions.Faction.on_new_banner(self) + --TODO: implement +end --??????????????