added playerfactions support, protecor_hud_interval and settings update
This commit is contained in:
@@ -13,6 +13,8 @@ local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S = dofile(MP .. "/intllib.lua")
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
-- Load support for factions
|
||||
local factions_available = minetest.global_exists("factions")
|
||||
|
||||
protector = {
|
||||
mod = "redo",
|
||||
@@ -58,6 +60,15 @@ end
|
||||
-- check for member name
|
||||
local is_member = function (meta, name)
|
||||
|
||||
if factions_available
|
||||
and meta:get_int("faction_members") == 1
|
||||
and factions.get_player_faction(name) ~= nil
|
||||
and factions.get_player_faction(meta:get_string("owner")) ==
|
||||
factions.get_player_faction(name) then
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
for _, n in pairs(get_member_list(meta)) do
|
||||
|
||||
if n == name then
|
||||
@@ -129,6 +140,19 @@ local protector_formspec = function(meta)
|
||||
local npp = protector_max_share_count -- max users added to protector list
|
||||
local i = 0
|
||||
|
||||
if factions_available
|
||||
and factions.get_player_faction(meta:get_string("owner")) then
|
||||
|
||||
formspec = formspec .. "checkbox[0,5;faction_members;"
|
||||
.. F(S("Allow faction access"))
|
||||
.. ";" .. (meta:get_int("faction_members") == 1 and
|
||||
"true" or "false") .. "]"
|
||||
|
||||
if npp > 8 then
|
||||
npp = 8
|
||||
end
|
||||
end
|
||||
|
||||
for n = 1, #members do
|
||||
|
||||
if i < npp then
|
||||
@@ -613,6 +637,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
-- add faction members
|
||||
if factions_available then
|
||||
meta:set_int("faction_members", fields.faction_members == "true" and 1 or 0)
|
||||
end
|
||||
|
||||
-- add member [+]
|
||||
if add_member_input then
|
||||
|
||||
|
||||
Reference in New Issue
Block a user