MT-Modder
2015-03-01 b8c902868115a0a607da35e208a422e430d46317
technic/tools/chainsaw.lua
@@ -14,11 +14,13 @@
   ["default:cactus"]     = true,
   ["default:tree"]       = true,
   ["default:apple"]      = true,
   ["default:pinetree"]   = true,
}
if chainsaw_leaves then
   timber_nodenames["default:leaves"] = true
   timber_nodenames["default:jungleleaves"] = true
   timber_nodenames["default:pine_needles"] = true
end
-- technic_worldgen defines rubber trees if moretrees isn't installed
@@ -33,32 +35,21 @@
-- Support moretrees if it is there
if minetest.get_modpath("moretrees") then
   timber_nodenames["moretrees:acacia_trunk"]                = true
   timber_nodenames["moretrees:apple_tree_trunk"]                 = true
   timber_nodenames["moretrees:apple_tree_trunk_sideways"]        = true
   timber_nodenames["moretrees:beech_trunk"]                      = true
   timber_nodenames["moretrees:beech_trunk_sideways"]             = true
   timber_nodenames["moretrees:birch_trunk"]                      = true
   timber_nodenames["moretrees:birch_trunk_sideways"]             = true
   timber_nodenames["moretrees:fir_trunk"]                        = true
   timber_nodenames["moretrees:fir_trunk_sideways"]               = true
   timber_nodenames["moretrees:oak_trunk"]                        = true
   timber_nodenames["moretrees:oak_trunk_sideways"]               = true
   timber_nodenames["moretrees:palm_trunk"]                       = true
   timber_nodenames["moretrees:palm_trunk_sideways"]              = true
   timber_nodenames["moretrees:pine_trunk"]                       = true
   timber_nodenames["moretrees:pine_trunk_sideways"]              = true
   timber_nodenames["moretrees:rubber_tree_trunk_sideways"]       = true
   timber_nodenames["moretrees:rubber_tree_trunk_sideways_empty"] = true
   timber_nodenames["moretrees:sequoia_trunk"]                    = true
   timber_nodenames["moretrees:sequoia_trunk_sideways"]           = true
   timber_nodenames["moretrees:spruce_trunk"]                     = true
   timber_nodenames["moretrees:spruce_trunk_sideways"]            = true
   timber_nodenames["moretrees:willow_trunk"]                     = true
   timber_nodenames["moretrees:willow_trunk_sideways"]            = true
   timber_nodenames["moretrees:jungletree_trunk"]                 = true
   timber_nodenames["moretrees:jungletree_trunk_sideways"]        = true
   if chainsaw_leaves then
      timber_nodenames["moretrees:acacia_leaves"]            = true
      timber_nodenames["moretrees:apple_tree_leaves"]        = true
      timber_nodenames["moretrees:oak_leaves"]               = true
      timber_nodenames["moretrees:fir_leaves"]               = true
@@ -74,6 +65,12 @@
      timber_nodenames["moretrees:jungletree_leaves_green"]  = true
      timber_nodenames["moretrees:jungletree_leaves_yellow"] = true
      timber_nodenames["moretrees:jungletree_leaves_red"]    = true
      timber_nodenames["moretrees:acorn"]                    = true
      timber_nodenames["moretrees:coconut"]                  = true
      timber_nodenames["moretrees:spruce_cone"]              = true
      timber_nodenames["moretrees:pine_cone"]                = true
      timber_nodenames["moretrees:fir_cone"]                 = true
      timber_nodenames["moretrees:apple_blossoms"]           = true
   end
end
@@ -121,10 +118,43 @@
-- Support farming_plus
if minetest.get_modpath("farming_plus") then
   if chainsaw_leaves then
      timber_nodenames["farming_plus:cocoa_leaves"] = true
      timber_nodenames["farming_plus:banana_leaves"] = true
      timber_nodenames["farming_plus:banana"]        = true
      timber_nodenames["farming_plus:cocoa_leaves"]  = true
      timber_nodenames["farming_plus:cocoa"]         = true
   end
end
-- Support nature
if minetest.get_modpath("nature") then
   if chainsaw_leaves then
      timber_nodenames["nature:blossom"] = true
   end
end
-- Support snow
if minetest.get_modpath("snow") then
   if chainsaw_leaves then
      timber_nodenames["snow:needles"] = true
      timber_nodenames["snow:needles_decorated"] = true
      timber_nodenames["snow:star"] = true
   end
end
-- Support vines (also generated by moretrees if available)
if minetest.get_modpath("vines") then
   if chainsaw_leaves then
      timber_nodenames["vines:vines"] = true
   end
end
if minetest.get_modpath("trunks") then
   if chainsaw_leaves then
      timber_nodenames["trunks:moss"] = true
      timber_nodenames["trunks:moss_fungus"] = true
      timber_nodenames["trunks:treeroot"] = true
   end
end
local S = technic.getter
@@ -314,17 +344,21 @@
      -- Send current charge to digging function so that the
      -- chainsaw will stop after digging a number of nodes
      meta.charge = chainsaw_dig(pointed_thing.under, meta.charge)
      technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge)
      itemstack:set_metadata(minetest.serialize(meta))
      if not technic.creative_mode then
         technic.set_RE_wear(itemstack, meta.charge, chainsaw_max_charge)
         itemstack:set_metadata(minetest.serialize(meta))
      end
      return itemstack
   end,
})
local mesecons_button = minetest.get_modpath("mesecons_button")
local trigger = mesecons_button and "mesecons_button:button_off" or "default:mese_crystal_fragment"
minetest.register_craft({
   output = "technic:chainsaw",
   recipe = {
      {"technic:stainless_steel_ingot", "mesecons_button:button_off", "technic:battery"},
      {"technic:stainless_steel_ingot", trigger,                      "technic:battery"},
      {"technic:fine_copper_wire",      "technic:motor",              "technic:battery"},
      {"",                              "",                           "technic:stainless_steel_ingot"},
   }