mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-25 10:10:41 +01:00
Fix "safe region" functionality errornously rejecting pos1-only commands (e.g. //sphere)
This commit is contained in:
parent
426f3b949f
commit
bcac45a476
@ -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 = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
|
||||
local safe_region, check_region, reset_pending = 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]
|
||||
@ -198,6 +198,8 @@ minetest.register_chatcommand("/reset", {
|
||||
worldedit.mark_pos1(name)
|
||||
worldedit.mark_pos2(name)
|
||||
worldedit.set_pos[name] = nil
|
||||
--make sure the user does not try to confirm an operation after resetting pos:
|
||||
reset_pending(name)
|
||||
worldedit.player_notify(name, "region reset")
|
||||
end,
|
||||
})
|
||||
|
@ -30,6 +30,10 @@ local function safe_region(callback, nodes_needed)
|
||||
end
|
||||
end
|
||||
|
||||
local function reset_pending(name)
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("/y", {
|
||||
params = "",
|
||||
description = "Confirm a pending operation",
|
||||
@ -40,15 +44,8 @@ minetest.register_chatcommand("/y", {
|
||||
return
|
||||
end
|
||||
|
||||
--obtain positions
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name, "no region selected")
|
||||
return
|
||||
end
|
||||
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil --reset pending operation
|
||||
callback(name, param, pos1, pos2)
|
||||
callback(name, param)
|
||||
end,
|
||||
})
|
||||
|
||||
@ -64,5 +61,5 @@ minetest.register_chatcommand("/n", {
|
||||
end,
|
||||
})
|
||||
|
||||
return safe_region, check_region
|
||||
|
||||
return safe_region, check_region, reset_pending
|
||||
|
Loading…
Reference in New Issue
Block a user