From abdf4d25d94d44a5183cc4d52f70f7e15f455c29 Mon Sep 17 00:00:00 2001 From: Supergoat666 <47240900+Supergoat666@users.noreply.github.com> Date: Tue, 28 Jul 2020 22:50:31 +0200 Subject: [PATCH] Add factions.version variable + factions.get_facts() + factions.player_is_in_faction(fname,player_name) to make easier the integration in other mods --- init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/init.lua b/init.lua index 49e87d2..3b6dd96 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,9 @@ local S, NS = dofile(MP.."/intllib.lua") -- Data factions = {} +-- This variable "version" can be used by other mods to check the compatibility of the mods +factions.version = 2 + local facts = {} local storage = minetest.get_mod_storage() if storage:get_string("facts") ~= "" then @@ -36,6 +39,17 @@ local function save_factions() end -- Data manipulation +function factions.get_facts() + return facts +end + +function factions.player_is_in_faction(fname, player_name) + if not minetest.player_exists(player_name) or facts[fname] == nil then + return false + end + return facts[fname].members[player_name] +end + function factions.get_player_faction(name) if not minetest.player_exists(name) then return false