added support for playerfactions new api (thanks louisroyer)
This commit is contained in:
parent
0702fad2db
commit
6d09dd559c
@ -60,6 +60,7 @@ Change log:
|
|||||||
- 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values.
|
- 3.0 - Added PlayerFactions support, 'protector_hud_interval' setting and listing in advanced settings for mod values.
|
||||||
- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet)
|
- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet)
|
||||||
- 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both. Added 'protector_msg' setting for player text.
|
- 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both. Added 'protector_msg' setting for player text.
|
||||||
|
- 3.3 - Added support for playerfactions new api (thanks louisroyer)
|
||||||
|
|
||||||
Lucky Blocks: 10
|
Lucky Blocks: 10
|
||||||
|
|
||||||
|
44
init.lua
44
init.lua
@ -64,12 +64,27 @@ end
|
|||||||
local is_member = function (meta, name)
|
local is_member = function (meta, name)
|
||||||
|
|
||||||
if factions_available
|
if factions_available
|
||||||
and meta:get_int("faction_members") == 1
|
and meta:get_int("faction_members") == 1 then
|
||||||
and factions.get_player_faction(name) ~= nil
|
|
||||||
and factions.get_player_faction(meta:get_string("owner")) ==
|
|
||||||
factions.get_player_faction(name) then
|
|
||||||
|
|
||||||
return true
|
if factions.version == nil then
|
||||||
|
|
||||||
|
-- backward compatibility
|
||||||
|
if factions.get_player_faction(name) ~= nil
|
||||||
|
and factions.get_player_faction(meta:get_string("owner")) ==
|
||||||
|
factions.get_player_faction(name) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- is member if player and owner share at least one faction
|
||||||
|
local owner_factions = factions.get_player_factions(name)
|
||||||
|
|
||||||
|
for _, f in ipairs(owner_factions) do
|
||||||
|
|
||||||
|
if factions.player_is_in_faction(f, owner) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, n in pairs(get_member_list(meta)) do
|
for _, n in pairs(get_member_list(meta)) do
|
||||||
@ -142,9 +157,24 @@ local protector_formspec = function(meta)
|
|||||||
local members = get_member_list(meta)
|
local members = get_member_list(meta)
|
||||||
local npp = protector_max_share_count -- max users added to protector list
|
local npp = protector_max_share_count -- max users added to protector list
|
||||||
local i = 0
|
local i = 0
|
||||||
|
local checkbox_faction = false
|
||||||
|
|
||||||
if factions_available
|
-- Display the checkbox only if the owner is member of at least 1 faction
|
||||||
and factions.get_player_faction(meta:get_string("owner")) then
|
if factions_available then
|
||||||
|
|
||||||
|
if factions.version == nil then
|
||||||
|
|
||||||
|
-- backward compatibility
|
||||||
|
if factions.get_player_faction(meta:get_string("owner")) then
|
||||||
|
checkbox_faction = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if next(factions.get_player_faction(meta:get_string("owner"))) then
|
||||||
|
checkbox_faction = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if checkbox_faction then
|
||||||
|
|
||||||
formspec = formspec .. "checkbox[0,5;faction_members;"
|
formspec = formspec .. "checkbox[0,5;faction_members;"
|
||||||
.. F(S("Allow faction access"))
|
.. F(S("Allow faction access"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user