From 932645b5a0ca8cbc93965945cda8d89f48c4bf3e Mon Sep 17 00:00:00 2001 From: Coder12a <38924418+Coder12a@users.noreply.github.com> Date: Thu, 25 Oct 2018 00:21:42 -0500 Subject: [PATCH] Add set_message_of_the_day command --- README.md | 16 +++++++++++++--- chatcommands.lua | 15 +++++++++++++++ factions.lua | 10 ++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4676fa5..1385b44 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,18 @@ Maybe expand on diplomacy. Write the forum topic better. -Add command to set the faction message of the day. - Code clean up and optimization. +Add short worded commands. + +Parcels should show up at a more accurate position just like in mc factions. + +Allow faction chest to become big when you place two chests by each other like in mc. + +mc style tnt. + +lag-free fire(if thats possible). + # COMPLETED BUT NEEDS TESTING LIST None. @@ -47,4 +55,6 @@ Make claim's depth not go to high or low. Or make it act like a protection block Add a show claim command (show small entity boxes like in protection mod). -Remove banner code. \ No newline at end of file +Remove banner code. + +Add command to set the faction message of the day. \ No newline at end of file diff --git a/chatcommands.lua b/chatcommands.lua index 3dfed30..c830789 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -421,6 +421,21 @@ factions.register_command("rank_privileges", { end },false) +factions.register_command("set_message_of_the_day", { + format = {"string"}, + faction_permissions = {"playerslist"}, + description = "Sets the message that shows up every time a faction member logs-in.", + global_privileges = {"faction_user"}, + on_success = function(player, faction, pos, parcelpos, args) + local s = "" + for i,l in pairs(args.strings) do + s = s .. l .. " " + end + faction:set_message_of_the_day("Message of the day: " .. s) + return true + end +},true) + if factions_config.faction_diplomacy then factions.register_command("send_alliance", { description = "Send an alliance request to another faction.", diff --git a/factions.lua b/factions.lua index 00143b8..2e99557 100644 --- a/factions.lua +++ b/factions.lua @@ -80,6 +80,8 @@ function factions.Faction:new(faction) default_leader_rank = "leader", --! @brief faction's description string description = "Default faction description.", + --! @brief faction's message of the day. + message_of_the_day = "", --! @brief list of players currently invited (can join with /f join) invited_players = {}, --! @brief table of claimed parcels (keys are parcelpos strings) @@ -394,6 +396,11 @@ function factions.Faction.set_leader(self, player) factions.save() end +function factions.Faction.set_message_of_the_day(self,text) + self.message_of_the_day = text + factions.save() +end + --! @brief check permissions for a given player --! @return boolean indicating permissions. Players not in faction always receive false function factions.Faction.has_permission(self, player, permission) @@ -977,6 +984,9 @@ function(player) if faction:has_permission(name, "diplomacy") then for _ in pairs(faction.request_inbox) do minetest.chat_send_player(name,"You have diplomatic requests in the inbox.") break end end + if faction.message_of_the_day ~= "" or faction.message_of_the_day ~= " " then + minetest.chat_send_player(name,faction.message_of_the_day) + end end end )