mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-22 07:13:50 +01:00
Add factions.version variable + factions.get_facts() + factions.player_is_in_faction(fname,player_name) to make easier the integration in other mods
This commit is contained in:
parent
15ec2ad3e1
commit
abdf4d25d9
14
init.lua
14
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
|
||||
|
Loading…
Reference in New Issue
Block a user