fix factions issue (thanks MisterE), tidy protector display removal
This commit is contained in:
parent
dc39c94703
commit
5672606432
1 changed files with 42 additions and 32 deletions
36
init.lua
36
init.lua
|
|
@ -65,7 +65,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- check for member name
|
-- check for member name
|
||||||
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 then
|
and meta:get_int("faction_members") == 1 then
|
||||||
|
|
@ -81,6 +81,9 @@ local is_member = function (meta, name)
|
||||||
else
|
else
|
||||||
-- is member if player and owner share at least one faction
|
-- is member if player and owner share at least one faction
|
||||||
local owner_factions = factions.get_player_factions(name)
|
local owner_factions = factions.get_player_factions(name)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
|
||||||
|
if owner_factions ~= nil and owner_factions ~= false then
|
||||||
|
|
||||||
for _, f in ipairs(owner_factions) do
|
for _, f in ipairs(owner_factions) do
|
||||||
|
|
||||||
|
|
@ -90,6 +93,7 @@ local is_member = function (meta, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for _, n in pairs(get_member_list(meta)) do
|
for _, n in pairs(get_member_list(meta)) do
|
||||||
|
|
||||||
|
|
@ -444,6 +448,19 @@ local check_overlap = function(itemstack, placer, pointed_thing)
|
||||||
end
|
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
|
-- temporary pos store
|
||||||
local player_pos = {}
|
local player_pos = {}
|
||||||
|
|
||||||
|
|
@ -521,17 +538,14 @@ minetest.register_node("protector:protect", {
|
||||||
|
|
||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
|
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = del_display
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
|
||||||
for _, v in ipairs(objects) do
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- default recipe and alternative for MineClone2
|
-- default recipe and alternative for MineClone2
|
||||||
if protector_recipe then
|
if protector_recipe then
|
||||||
|
|
||||||
if minetest.registered_items["default:stone"] then
|
if minetest.registered_items["default:stone"] then
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:protect",
|
output = "protector:protect",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
|
@ -541,6 +555,7 @@ if protector_recipe then
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "protector:protect",
|
output = "protector:protect",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
|
@ -627,12 +642,7 @@ minetest.register_node("protector:protect2", {
|
||||||
|
|
||||||
on_blast = function() end,
|
on_blast = function() end,
|
||||||
|
|
||||||
after_destruct = function(pos, oldnode)
|
after_destruct = del_display
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 0.5)
|
|
||||||
for _, v in ipairs(objects) do
|
|
||||||
v:remove()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- recipes to switch between protectors
|
-- recipes to switch between protectors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue