1 local safe_region_callback = {}
\r
3 --`count` is the number of nodes that would possibly be modified
\r
4 --`callback` is a callback to run when the user confirms
\r
5 local function safe_region(name, count, callback)
\r
6 if count < 20000 then
\r
10 --save callback to call later
\r
11 safe_region_callback[name] = callback
\r
12 worldedit.player_notify(name, "WARNING: this operation could affect up to " .. count .. " nodes; type //y to continue or //n to cancel")
\r
15 local function reset_pending(name)
\r
16 safe_region_callback[name] = nil
\r
19 minetest.register_chatcommand("/y", {
\r
21 description = "Confirm a pending operation",
\r
22 func = function(name)
\r
23 local callback = safe_region_callback[name]
\r
24 if not callback then
\r
25 worldedit.player_notify(name, "no operation pending")
\r
34 minetest.register_chatcommand("/n", {
\r
36 description = "Abort a pending operation",
\r
37 func = function(name)
\r
38 if not safe_region_callback[name] then
\r
39 worldedit.player_notify(name, "no operation pending")
\r
48 return safe_region, reset_pending
\r