mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-06-30 15:10:45 +02:00
Version MFF
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
local safe_region_callback = {}
|
||||
local safe_region_param = {}
|
||||
|
||||
check_region = function(name, param)
|
||||
local function check_region(name, param)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] --obtain positions
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name, "no region selected")
|
||||
@ -12,7 +12,7 @@ end
|
||||
|
||||
--`callback` is a callback to run when the user confirms
|
||||
--`nodes_needed` is a function accepting `param`, `pos1`, and `pos2` to calculate the number of nodes needed
|
||||
safe_region = function(callback, nodes_needed)
|
||||
local function safe_region(callback, nodes_needed)
|
||||
--default node volume calculation
|
||||
nodes_needed = nodes_needed or check_region
|
||||
|
||||
@ -30,6 +30,10 @@ safe_region = function(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,
|
||||
})
|
||||
|
||||
@ -63,3 +60,6 @@ minetest.register_chatcommand("/n", {
|
||||
safe_region_callback[name], safe_region_param[name] = nil, nil
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
return safe_region, check_region, reset_pending
|
||||
|
Reference in New Issue
Block a user