fix factions issue (thanks MisterE), tidy protector display removal

This commit is contained in:
tenplus1 2020-12-25 08:24:09 +00:00
parent dc39c94703
commit 5672606432

@ -65,7 +65,7 @@ end
-- check for member name
local is_member = function (meta, name)
local is_member = function(meta, name)
if factions_available
and meta:get_int("faction_members") == 1 then
@ -81,11 +81,15 @@ local is_member = function (meta, name)
else
-- is member if player and owner share at least one faction
local owner_factions = factions.get_player_factions(name)
local owner = meta:get_string("owner")
for _, f in ipairs(owner_factions) do
if owner_factions ~= nil and owner_factions ~= false then
if factions.player_is_in_faction(f, owner) then
return true
for _, f in ipairs(owner_factions) do
if factions.player_is_in_faction(f, owner) then
return true
end
end
end
end
@ -444,6 +448,19 @@ local check_overlap = function(itemstack, placer, pointed_thing)
end
-- remove protector display entities
local del_display = function(pos)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
if v:get_luaentity().name == "protector:display" then
v:remove()
end
end
end
-- temporary pos store
local player_pos = {}
@ -521,34 +538,32 @@ minetest.register_node("protector:protect", {
on_blast = function() end,
after_destruct = function(pos, oldnode)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
v:remove()
end
end,
after_destruct = del_display
})
-- default recipe and alternative for MineClone2
if protector_recipe then
if minetest.registered_items["default:stone"] then
minetest.register_craft({
output = "protector:protect",
recipe = {
{"default:stone", "default:stone", "default:stone"},
{"default:stone", "default:gold_ingot", "default:stone"},
{"default:stone", "default:stone", "default:stone"},
}
})
minetest.register_craft({
output = "protector:protect",
recipe = {
{"default:stone", "default:stone", "default:stone"},
{"default:stone", "default:gold_ingot", "default:stone"},
{"default:stone", "default:stone", "default:stone"},
}
})
else
minetest.register_craft({
output = "protector:protect",
recipe = {
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"},
{"mcl_core:stone", "mcl_core:gold_ingot", "mcl_core:stone"},
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"},
}
})
minetest.register_craft({
output = "protector:protect",
recipe = {
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"},
{"mcl_core:stone", "mcl_core:gold_ingot", "mcl_core:stone"},
{"mcl_core:stone", "mcl_core:stone", "mcl_core:stone"},
}
})
end
end
@ -627,12 +642,7 @@ minetest.register_node("protector:protect2", {
on_blast = function() end,
after_destruct = function(pos, oldnode)
local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do
v:remove()
end
end,
after_destruct = del_display
})
-- recipes to switch between protectors