mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-21 20:42:21 +01:00
Make smallest area concept optional (#80)
This restores the behaviour to before #79.
This commit is contained in:
parent
9b6fea1473
commit
d2b227eca6
27
api.lua
27
api.lua
@ -114,37 +114,44 @@ function areas:getSmallestAreaAtPos(pos)
|
||||
end
|
||||
|
||||
-- Checks if the area is unprotected, open, owned by player
|
||||
-- or player is part of faction of smallest area at position.
|
||||
-- or player is part of faction of [smallest] area at position.
|
||||
function areas:canInteract(pos, name)
|
||||
if minetest.check_player_privs(name, self.adminPrivs) then
|
||||
return true
|
||||
end
|
||||
local area = self:getSmallestAreaAtPos(pos)
|
||||
-- No area, player owns it or area is open
|
||||
if not area
|
||||
or area.owner == name
|
||||
or area.open
|
||||
then
|
||||
local areas_list
|
||||
if areas.config.use_smallest_area_precedence then
|
||||
local smallest_area, _ = self:getSmallestAreaAtPos(pos)
|
||||
areas_list = { smallest_area }
|
||||
else
|
||||
areas_list = self:getAreasAtPos(pos)
|
||||
end
|
||||
local owned = false
|
||||
for _, area in pairs(areas_list) do
|
||||
-- Player owns the area or area is open
|
||||
if area.owner == name or area.open then
|
||||
return true
|
||||
elseif areas.factions_available and area.faction_open then
|
||||
if (factions.version or 0) < 2 then
|
||||
local faction_name = factions.get_player_faction(name)
|
||||
if faction_name then
|
||||
for _, fname in ipairs(area.faction_open or {}) do
|
||||
for _, fname in ipairs(area.faction_open) do
|
||||
if faction_name == fname then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for _, fname in ipairs(area.faction_open or {}) do
|
||||
for _, fname in ipairs(area.faction_open) do
|
||||
if factions.player_is_in_faction(fname, name) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
owned = true
|
||||
end
|
||||
return not owned
|
||||
end
|
||||
|
||||
-- Returns a table (list) of all players that own an area
|
||||
|
@ -3,6 +3,20 @@
|
||||
# Static paths do not work well with settings
|
||||
#areas.filename (Configuration file path) string (world_path)/areas.dat
|
||||
|
||||
# Use smallest area volume precedence concept. (experimental; may change)
|
||||
#
|
||||
# If set to `true`:
|
||||
# The interaction permission is defined by the smallest area volume that
|
||||
# contains the interaction position. Granting access to areas is achieved
|
||||
# by factions instead of using `/add_owner`.
|
||||
# This allows players to have private areas within a greater open/shared
|
||||
# area and also define open/shared areas within those private areas.
|
||||
# If set to `false`: (default)
|
||||
# Interacting is permitted if the interaction position resides in any of the
|
||||
# player's own areas, shared or open areas.
|
||||
# This permission is not impacted by more restrictive, intersecting areas.
|
||||
areas.use_smallest_area_precedence (Smallest area rules) bool false
|
||||
|
||||
# Allow players with a privilege create their own areas using /protect
|
||||
# within the specified size and amount limits.
|
||||
areas.self_protection (Self protection) bool false
|
||||
|
Loading…
Reference in New Issue
Block a user