1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2025-07-03 16:40:38 +02:00

move logic to method

This commit is contained in:
Isidor Zeuner
2017-07-01 10:23:51 +02:00
parent 3de6cdcf84
commit 19c9ca179b
2 changed files with 103 additions and 102 deletions

View File

@ -4,6 +4,31 @@ if minetest.get_modpath("areas") then
area_protection.areas = areas
end
local area_protection.interaction_allowed = function(
area_protection,
description,
pos1,
pos2,
player_name
)
if area_protection.areas then
local allowed, conflicting = area_protection.areas:canInteractInArea(
pos1,
pos2,
player_name,
false
)
if not allowed then
worldedit.player_notify(
player_name,
description .. " conflicts with non-owned region " .. conflicting
)
end
return allowed
end
return true
end
local safe_region_callback = {}
local safe_region_param = {}
@ -13,20 +38,14 @@ local function check_region(name, param)
worldedit.player_notify(name, "no region selected")
return nil
end
if nil ~= area_protection.areas then
local allowed, conflicting = area_protection.areas:canInteractInArea(
pos1,
pos2,
name,
false
)
if false == allowed then
worldedit.player_notify(
name,
"region conflicts with non-owned region " .. conflicting
)
return nil
end
local allowed = area_protection:interaction_allowed(
"region",
pos1,
pos2,
name
)
if not allowed then
return nil
end
return worldedit.volume(pos1, pos2)
end