Skip to content

Commit

Permalink
Fix leaking {safe,check}_region
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed May 16, 2015
1 parent 6b2fe39 commit 163dffc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions worldedit_commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if minetest.place_schematic then
end

dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua")
dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua")
safe_region = rawget(_G, "safe_region") or function(callback) return callback end
local safe_region, check_region = 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]
Expand Down
7 changes: 5 additions & 2 deletions worldedit_commands/safe.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -63,3 +63,6 @@ minetest.register_chatcommand("/n", {
safe_region_callback[name], safe_region_param[name] = nil, nil
end,
})

return safe_region, check_region

0 comments on commit 163dffc

Please sign in to comment.