mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-22 12:52:22 +01:00
Add require_protection and node_ownership_legacy settings
require_protection: Disallows interactions outside of owned areas node_ownership_legacy: Skip 9+ year old compatibility code by default
This commit is contained in:
parent
4018c0d204
commit
f52454edec
7
api.lua
7
api.lua
@ -84,10 +84,15 @@ end
|
|||||||
|
|
||||||
-- Checks if the area is unprotected or owned by you
|
-- Checks if the area is unprotected or owned by you
|
||||||
function areas:canInteract(pos, name)
|
function areas:canInteract(pos, name)
|
||||||
|
if name == "" then
|
||||||
|
return true -- Mods, namely minetest.item_place_node
|
||||||
|
end
|
||||||
if minetest.check_player_privs(name, self.adminPrivs) then
|
if minetest.check_player_privs(name, self.adminPrivs) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
local owned = false
|
|
||||||
|
-- Disallow interaction by default when the restrictive setting is enabled
|
||||||
|
local owned = areas.config.require_protection
|
||||||
for _, area in pairs(self:getAreasAtPos(pos)) do
|
for _, area in pairs(self:getAreasAtPos(pos)) do
|
||||||
if area.owner == name or area.open then
|
if area.owner == name or area.open then
|
||||||
return true
|
return true
|
||||||
|
2
init.lua
2
init.lua
@ -16,7 +16,9 @@ dofile(areas.modpath.."/internal.lua")
|
|||||||
dofile(areas.modpath.."/chatcommands.lua")
|
dofile(areas.modpath.."/chatcommands.lua")
|
||||||
dofile(areas.modpath.."/pos.lua")
|
dofile(areas.modpath.."/pos.lua")
|
||||||
dofile(areas.modpath.."/interact.lua")
|
dofile(areas.modpath.."/interact.lua")
|
||||||
|
if areas.config.node_ownership_legacy then
|
||||||
dofile(areas.modpath.."/legacy.lua")
|
dofile(areas.modpath.."/legacy.lua")
|
||||||
|
end
|
||||||
dofile(areas.modpath.."/hud.lua")
|
dofile(areas.modpath.."/hud.lua")
|
||||||
|
|
||||||
areas:load()
|
areas:load()
|
||||||
|
13
interact.lua
13
interact.lua
@ -9,11 +9,20 @@ function minetest.is_protected(pos, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_protection_violation(function(pos, name)
|
minetest.register_on_protection_violation(function(pos, name)
|
||||||
if not areas:canInteract(pos, name) then
|
if areas:canInteract(pos, name) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local owners = areas:getNodeOwners(pos)
|
local owners = areas:getNodeOwners(pos)
|
||||||
|
if #owners == 0 then
|
||||||
|
-- When require_protection=true
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
S("@1 may not be accessed.",
|
||||||
|
minetest.pos_to_string(pos)))
|
||||||
|
return
|
||||||
|
end
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("@1 is protected by @2.",
|
S("@1 is protected by @2.",
|
||||||
minetest.pos_to_string(pos),
|
minetest.pos_to_string(pos),
|
||||||
table.concat(owners, ", ")))
|
table.concat(owners, ", ")))
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
@ -8,30 +8,34 @@
|
|||||||
areas.self_protection (Self protection) bool false
|
areas.self_protection (Self protection) bool false
|
||||||
|
|
||||||
# Self protection: Privilege required to protect an area
|
# Self protection: Privilege required to protect an area
|
||||||
areas.self_protection_privilege (Self protection: Required privs) string interact
|
areas.self_protection_privilege (Self protection: Required priv) string interact
|
||||||
|
|
||||||
# Refresh delay for the name displays in the HUD in seconds
|
# Limits interactions of players to the areas they have access to.
|
||||||
|
# This setting is very restrictive and is not recommended for open-world games.
|
||||||
|
areas.require_protection (Require protection) bool false
|
||||||
|
|
||||||
|
# Area name HUD refresh delay in seconds
|
||||||
areas.tick (HUD update delay) float 0.5 0 100
|
areas.tick (HUD update delay) float 0.5 0 100
|
||||||
|
|
||||||
# Enable the legacy owner_defs metatable mode. Untested and possibly unstable
|
# Enable the legacy owner_defs metatable mode. Untested and possibly unstable
|
||||||
areas.legacy_table (Legacy owner_defs metatable) bool false
|
areas.node_ownership_legacy (node_ownership compatibility) bool false
|
||||||
|
|
||||||
[Self protection (normal)]
|
[Self protection (normal)]
|
||||||
|
|
||||||
# Self protection (normal): Maximal size of the protectable area
|
# Maximal size of the protectable area
|
||||||
# Only enter positive whole numbers for the coordinate values or you'll mess up stuff.
|
# Only enter positive whole numbers for the coordinate values or you'll mess up stuff.
|
||||||
areas.self_protection_max_size (Maximal area size) v3f (64, 128, 64)
|
areas.self_protection_max_size (Maximal area size) v3f (64, 128, 64)
|
||||||
|
|
||||||
# Self protection (normal): Maximal amount of protected areas per player
|
# Maximal amount of protected areas per player
|
||||||
areas.self_protection_max_areas (Maximal area count) int 4
|
areas.self_protection_max_areas (Maximal area count) int 4
|
||||||
|
|
||||||
[Self protection (high)]
|
[Self protection (high)]
|
||||||
|
|
||||||
# Self protection (normal): Maximal size of the protectable area
|
# For players with the 'areas_high_limit' privilege.
|
||||||
# This setting applies for plyaers with the privilege 'areas_high_limit'
|
# Maximal size of the protectable area
|
||||||
|
# This setting applies for players with the privilege 'areas_high_limit'
|
||||||
areas.self_protection_max_size_high (Maximal area size) v3f (512, 512, 512)
|
areas.self_protection_max_size_high (Maximal area size) v3f (512, 512, 512)
|
||||||
|
|
||||||
# Self protection (normal): Maximal amount of protected areas per player
|
# For players with the 'areas_high_limit' privilege.
|
||||||
# Only enter positive whole numbers for the coordinate values or you'll mess up stuff.
|
# Maximal amount of protected areas per player
|
||||||
# This setting applies for plyaers with the privilege 'areas_high_limit'
|
|
||||||
areas.self_protection_max_areas_high (Maximal area count) float 32
|
areas.self_protection_max_areas_high (Maximal area count) float 32
|
||||||
|
Loading…
Reference in New Issue
Block a user