Konstantin Oblaukhov
2013-07-06 8be389e774a99ec5d08ca86b3902bb98310fd58d
technic/chainsaw.lua
@@ -3,7 +3,7 @@
local chainsaw_charge_per_node = 12    -- 12    - Gives 2500 nodes on a single charge (about 50 complete normal trees)
local chainsaw_leaves          = true  -- true  - Cut down entire trees, leaves and all
register_power_tool ("technic:chainsaw",chainsaw_max_charge)
technic.register_LV_power_tool ("technic:chainsaw",chainsaw_max_charge)
minetest.register_tool("technic:chainsaw", {
        description = "Chainsaw",
@@ -20,7 +20,7 @@
                        if charge < chainsaw_charge_per_node then return end -- only cut if charged
                        charge=chainsaw_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,charge)
                        set_RE_wear(item,charge,chainsaw_max_charge)
                        technic.set_RE_wear(item,charge,chainsaw_max_charge)
                        meta["charge"]=charge
                        item["metadata"]=set_item_meta(meta)
                        itemstack:replace(item)
@@ -138,12 +138,22 @@
        timber_nodenames["growing_cactus:branch_xx"]                    = true
end
-- Support farming_plus if it is there
if( minetest.get_modpath("farming_plus") ~= nil ) then
   if chainsaw_leaves == true then
      timber_nodenames["farming_plus:cocoa_leaves"] = true
   end
end
-- Table for saving what was sawed down
local produced
-- Saw down trees entry point
chainsaw_dig_it = function(pos, player,current_charge)
        local remaining_charge=current_charge
        -- Save the currently installed dropping mechanism so we can restore it.
   local original_handle_node_drops = minetest.handle_node_drops
        -- A bit of trickery here: use a different node drop callback
        -- and restore the original afterwards.
@@ -194,9 +204,6 @@
                end
        end
end
-- Save the currently installed dropping mechanism so we can restore it.
local original_handle_node_drops = minetest.handle_node_drops
-- This function does all the hard work. Recursively we dig the node at hand
-- if it is in the table and then search the surroundings for more stuff to dig.