mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-07-03 08:30:36 +02:00
basic area protection support
This commit is contained in:
@ -13,7 +13,7 @@ end
|
||||
dofile(minetest.get_modpath("worldedit_commands") .. "/cuboid.lua")
|
||||
dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua")
|
||||
dofile(minetest.get_modpath("worldedit_commands") .. "/wand.lua")
|
||||
local safe_region, check_region, reset_pending = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
|
||||
local safe_region, check_region, reset_pending, area_protection = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
|
||||
|
||||
local function get_position(name) --position 1 retrieval function for when not using `safe_region`
|
||||
local pos1 = worldedit.pos1[name]
|
||||
@ -409,6 +409,13 @@ minetest.register_chatcommand("/mix", {
|
||||
})
|
||||
|
||||
local check_replace = function(name, param)
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"check_replace not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
local found, _, searchnode, replacenode = param:find("^([^%s]+)%s+(.+)$")
|
||||
if found == nil then
|
||||
worldedit.player_notify(name, "invalid usage: " .. param)
|
||||
@ -456,8 +463,11 @@ minetest.register_chatcommand("/replaceinverse", {
|
||||
})
|
||||
|
||||
local check_sphere = function(name, param)
|
||||
if worldedit.pos1[name] == nil then
|
||||
worldedit.player_notify(name, "no position 1 selected")
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"check_sphere not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
local found, _, radius, nodename = param:find("^(%d+)%s+(.+)$")
|
||||
@ -495,6 +505,13 @@ minetest.register_chatcommand("/sphere", {
|
||||
})
|
||||
|
||||
local check_dome = function(name, param)
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"check_dome not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
if worldedit.pos1[name] == nil then
|
||||
worldedit.player_notify(name, "no position 1 selected")
|
||||
return nil
|
||||
@ -534,6 +551,13 @@ minetest.register_chatcommand("/dome", {
|
||||
})
|
||||
|
||||
local check_cylinder = function(name, param)
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"check_cylinder not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
if worldedit.pos1[name] == nil then
|
||||
worldedit.player_notify(name, "no position 1 selected")
|
||||
return nil
|
||||
@ -583,6 +607,13 @@ minetest.register_chatcommand("/cylinder", {
|
||||
})
|
||||
|
||||
local check_pyramid = function(name, param)
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"check_pyramid not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
if worldedit.pos1[name] == nil then
|
||||
worldedit.player_notify(name, "no position 1 selected")
|
||||
return nil
|
||||
@ -643,6 +674,13 @@ minetest.register_chatcommand("/spiral", {
|
||||
worldedit.player_notify(name, count .. " nodes added")
|
||||
end,
|
||||
function(name, param)
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"/spiral not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
if worldedit.pos1[name] == nil then
|
||||
worldedit.player_notify(name, "no position 1 selected")
|
||||
return nil
|
||||
@ -766,6 +804,13 @@ 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 then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"/stack2 not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
return count
|
||||
end)(name,param) -- more hax --wip: clean this up a little bit
|
||||
end
|
||||
@ -791,6 +836,13 @@ minetest.register_chatcommand("/stretch", {
|
||||
worldedit.player_notify(name, count .. " nodes stretched")
|
||||
end,
|
||||
function(name, param)
|
||||
if nil ~= area_protection.areas then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"/stretch not yet supported with area protection"
|
||||
)
|
||||
return nil
|
||||
end
|
||||
local found, _, stretchx, stretchy, stretchz = param:find("^(%d+)%s+(%d+)%s+(%d+)$")
|
||||
if found == nil then
|
||||
worldedit.player_notify(name, "invalid usage: " .. param)
|
||||
@ -1071,6 +1123,13 @@ 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 then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"/load not yet supported with area protection"
|
||||
)
|
||||
return
|
||||
end
|
||||
local pos = get_position(name)
|
||||
if pos == nil then return end
|
||||
|
||||
@ -1187,6 +1246,13 @@ 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 then
|
||||
worldedit.player_notify(
|
||||
name,
|
||||
"/mtschemplace not yet supported with area protection"
|
||||
)
|
||||
return
|
||||
end
|
||||
if param == "" then
|
||||
worldedit.player_notify(name, "no filename specified")
|
||||
return
|
||||
|
Reference in New Issue
Block a user