---`callback` is a callback to run when the user confirms\r
---`nodes_needed` is a function accepting `param`, `pos1`, and `pos2` to calculate the number of nodes needed\r
-safe_region = function(callback, nodes_needed)\r
- --default node volume calculation\r
- nodes_needed = nodes_needed or check_region\r
-\r
- return function(name, param)\r
- --check if the operation applies to a safe number of nodes\r
- local count = nodes_needed(name, param)\r
- if count == nil then return end --invalid command\r
- if count < 10000 then\r
- return callback(name, param)\r
- end\r
-\r
- --save callback to call later\r
- safe_region_callback, safe_region_name, safe_region_param = callback, name, param\r
- worldedit.player_notify(name, "WARNING: this operation could affect up to " .. count .. " nodes; type //y to continue or //n to cancel")\r
- end\r