summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-08-22 19:59:57 -0400
committerShadowNinja <shadowninja@minetest.net>2014-08-22 20:01:15 -0400
commit16302cffce1e127ba3527dc2163094aec9a1630c (patch)
tree009df3263d43a8ee56fe8769aff2dc060587c65d
parent78646b2d898031055fd7969768abb9baf6b3fb87 (diff)
Fix chainsaw placing drops and playing sounds at tops of trees
-rw-r--r--technic/tools/chainsaw.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/technic/tools/chainsaw.lua b/technic/tools/chainsaw.lua
index eaa33bf..36422d9 100644
--- a/technic/tools/chainsaw.lua
+++ b/technic/tools/chainsaw.lua
@@ -150,8 +150,10 @@ end
--- Iterator over positions to try to saw around a sawed node.
-- This returns nodes in a 3x2x3 area. It does not return lower (y) positions
-- to prevent the chainsaw from cutting down nodes below the cutting position.
--- @param pos Reference to sawing position. Note that this is overridden.
+-- @param pos Sawing position.
local function iterSawTries(pos)
+ -- Copy position to prevent mangling it
+ local pos = vector.new(pos)
-- Shift the position down on the x and z axes
pos.x, pos.z = pos.x - 1, pos.z - 1
-- Save our starting position for reseting it later
@@ -199,12 +201,12 @@ local function recursive_dig(pos, remaining_charge)
remaining_charge = remaining_charge - chainsaw_charge_per_node
-- Check surroundings and run recursively if any charge left
- for pos in iterSawTries(pos) do
+ for npos in iterSawTries(pos) do
if remaining_charge < chainsaw_charge_per_node then
break
end
- if timber_nodenames[minetest.get_node(pos).name] then
- remaining_charge = recursive_dig(pos, remaining_charge)
+ if timber_nodenames[minetest.get_node(npos).name] then
+ remaining_charge = recursive_dig(npos, remaining_charge)
end
end
return remaining_charge