factions/protection_override.lua
Coder12a 308932b9b5 Major update:
Add new features to claim and unclaim.
Sort help from a-z.
Sort functions into diff lua files.
2019-05-02 23:05:52 -05:00

37 lines
1.4 KiB
Lua

local default_is_protected = minetest.is_protected
minetest.is_protected = function(pos, player)
local y = pos.y
if factions_config.protection_depth_height_limit and (pos.y < factions_config.protection_max_depth or pos.y > factions_config.protection_max_height) then
return false
end
local parcelpos = factions.get_parcel_pos(pos)
local parcel_faction, parcel_fac_name = factions.get_parcel_faction(parcelpos)
local player_faction, player_fac_name = factions.get_player_faction(player)
-- no faction
if not parcel_faction then
return default_is_protected(pos, player)
elseif player_faction then
if parcel_faction.name == player_faction.name then
if factions.has_permission(parcel_fac_name, player, "pain_build") then
local p = minetest.get_player_by_name(player)
p:set_hp(p:get_hp() - 0.5)
end
return not (factions.has_permission(parcel_fac_name, player, "build") or factions.has_permission(parcel_fac_name, player, "pain_build"))
elseif parcel_faction.allies[player_faction.name] then
if factions.has_permission(player_fac_name, player, "pain_build") then
local p = minetest.get_player_by_name(player)
p:set_hp(p:get_hp() - 0.5)
end
return not (factions.has_permission(player_fac_name, player, "build") or factions.has_permission(player_fac_name, player, "pain_build"))
else
return true
end
else
return true
end
end