move logic to method

This commit is contained in:
Isidor Zeuner 2017-07-01 10:31:46 +02:00
parent 19c9ca179b
commit 443614f704
2 changed files with 19 additions and 6 deletions

View File

@ -656,7 +656,7 @@ minetest.register_chatcommand("/cylinder", {
})
local check_pyramid = function(name, param)
if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then
if area_protection:interaction_restrictions(name) then
worldedit.player_notify(
name,
"check_pyramid not yet supported with area protection"
@ -723,7 +723,7 @@ minetest.register_chatcommand("/spiral", {
worldedit.player_notify(name, count .. " nodes added")
end,
function(name, param)
if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then
if area_protection:interaction_restrictions(name) then
worldedit.player_notify(
name,
"/spiral not yet supported with area protection"
@ -853,7 +853,7 @@ minetest.register_chatcommand("/stack2", {
worldedit.stack2(pos1, pos2, {x=x, y=y, z=z}, repetitions,
function() worldedit.player_notify(name, count .. " nodes stacked") end)
end, function()
if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then
if area_protection:interaction_restrictions(name) then
worldedit.player_notify(
name,
"/stack2 not yet supported with area protection"
@ -885,7 +885,7 @@ minetest.register_chatcommand("/stretch", {
worldedit.player_notify(name, count .. " nodes stretched")
end,
function(name, param)
if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then
if area_protection:interaction_restrictions(name) then
worldedit.player_notify(
name,
"/stretch not yet supported with area protection"
@ -1172,7 +1172,7 @@ minetest.register_chatcommand("/load", {
description = "Load nodes from \"(world folder)/schems/<file>[.we[m]]\" with position 1 of the current WorldEdit region as the origin",
privs = {worldedit=true},
func = function(name, param)
if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then
if area_protection:interaction_restrictions(name) then
worldedit.player_notify(
name,
"/load not yet supported with area protection"
@ -1295,7 +1295,7 @@ minetest.register_chatcommand("/mtschemplace", {
description = "Load nodes from \"(world folder)/schems/<file>.mts\" with position 1 of the current WorldEdit region as the origin",
privs = {worldedit=true},
func = function(name, param)
if nil ~= area_protection.areas and not minetest.check_player_privs(name, {areas = true}) then
if area_protection:interaction_restrictions(name) then
worldedit.player_notify(
name,
"/mtschemplace not yet supported with area protection"

View File

@ -4,6 +4,19 @@ if minetest.get_modpath("areas") then
area_protection.areas = areas
end
local area_protection.interaction_restrictions = function(
area_protection,
player_name
)
if area_protection.areas then
if minetest.check_player_privs(name, {areas = true}) then
return false
end
return true
end
return false
end
local area_protection.interaction_allowed = function(
area_protection,
description,