1 local safe_region_callback = {}
\r
3 worldedit._override_safe_regions = false -- internal use ONLY!
\r
5 --`count` is the number of nodes that would possibly be modified
\r
6 --`callback` is a callback to run when the user confirms
\r
7 local function safe_region(name, count, callback)
\r
8 if worldedit._override_safe_regions or count < 10000 then
\r
12 --save callback to call later
\r
13 safe_region_callback[name] = callback
\r
14 worldedit.player_notify(name, "WARNING: this operation could affect up to " .. count .. " nodes; type //y to continue or //n to cancel")
\r
17 local function reset_pending(name)
\r
18 safe_region_callback[name] = nil
\r
21 minetest.register_chatcommand("/y", {
\r
23 description = "Confirm a pending operation",
\r
24 func = function(name)
\r
25 local callback = safe_region_callback[name]
\r
26 if not callback then
\r
27 worldedit.player_notify(name, "no operation pending")
\r
36 minetest.register_chatcommand("/n", {
\r
38 description = "Abort a pending operation",
\r
39 func = function(name)
\r
40 if not safe_region_callback[name] then
\r
41 worldedit.player_notify(name, "no operation pending")
\r
50 return safe_region, reset_pending
\r