Add cool_trees support to the chainsaw (#511)

Make list of timber node names less repetitive
This commit is contained in:
coil 2019-09-07 11:02:21 +00:00 committed by SmallJoker
parent 768fbecc64
commit e66bb281a4

@ -7,158 +7,153 @@ local chainsaw_charge_per_node = 12
-- if this is disabled.
local chainsaw_leaves = true
-- The default trees
local timber_nodenames = {
["default:acacia_tree"] = true,
["default:aspen_tree"] = true,
["default:jungletree"] = true,
["default:papyrus"] = true,
["default:cactus"] = true,
["default:tree"] = true,
["default:apple"] = true,
["default:pine_tree"] = true,
-- First value is node name; second is whether the node is considered even if chainsaw_leaves is false.
local nodes = {
-- The default trees
{"default:acacia_tree", true},
{"default:aspen_tree", true},
{"default:jungletree", true},
{"default:papyrus", true},
{"default:cactus", true},
{"default:tree", true},
{"default:apple", true},
{"default:pine_tree", true},
{"default:acacia_leaves", false},
{"default:aspen_leaves", false},
{"default:leaves", false},
{"default:jungleleaves", false},
{"default:pine_needles", false},
-- Rubber trees from moretrees or technic_worldgen if moretrees isn't installed
{"moretrees:rubber_tree_trunk_empty", true},
{"moretrees:rubber_tree_trunk", true},
{"moretrees:rubber_tree_leaves", false},
-- Support moretrees
{"moretrees:acacia_trunk", true},
{"moretrees:apple_tree_trunk", true},
{"moretrees:beech_trunk", true},
{"moretrees:birch_trunk", true},
{"moretrees:fir_trunk", true},
{"moretrees:oak_trunk", true},
{"moretrees:palm_trunk", true},
{"moretrees:pine_trunk", true},
{"moretrees:sequoia_trunk", true},
{"moretrees:spruce_trunk", true},
{"moretrees:willow_trunk", true},
{"moretrees:jungletree_trunk", true},
{"moretrees:poplar_trunk", true},
{"moretrees:acacia_leaves", false},
{"moretrees:apple_tree_leaves", false},
{"moretrees:oak_leaves", false},
{"moretrees:fir_leaves", false},
{"moretrees:fir_leaves_bright", false},
{"moretrees:sequoia_leaves", false},
{"moretrees:birch_leaves", false},
{"moretrees:birch_leaves", false},
{"moretrees:palm_leaves", false},
{"moretrees:spruce_leaves", false},
{"moretrees:spruce_leaves", false},
{"moretrees:pine_leaves", false},
{"moretrees:willow_leaves", false},
{"moretrees:jungletree_leaves_green", false},
{"moretrees:jungletree_leaves_yellow", false},
{"moretrees:jungletree_leaves_red", false},
{"moretrees:acorn", false},
{"moretrees:coconut", false},
{"moretrees:spruce_cone", false},
{"moretrees:pine_cone", false},
{"moretrees:fir_cone", false},
{"moretrees:apple_blossoms", false},
{"moretrees:poplar_leaves", false},
-- Support growing_trees
{"growing_trees:trunk", true},
{"growing_trees:medium_trunk", true},
{"growing_trees:big_trunk", true},
{"growing_trees:trunk_top", true},
{"growing_trees:trunk_sprout", true},
{"growing_trees:branch_sprout", true},
{"growing_trees:branch", true},
{"growing_trees:branch_xmzm", true},
{"growing_trees:branch_xpzm", true},
{"growing_trees:branch_xmzp", true},
{"growing_trees:branch_xpzp", true},
{"growing_trees:branch_zz", true},
{"growing_trees:branch_xx", true},
{"growing_trees:leaves", false},
-- Support cool_trees
{"bamboo:trunk", true},
{"bamboo:leaves", false},
{"birch:trunk", true},
{"birch:leaves", false},
{"cherrytree:trunk", true},
{"cherrytree:blossom_leaves", false},
{"cherrytree:leaves", false},
{"chestnuttree:trunk", true},
{"chestnuttree:leaves", false},
{"clementinetree:trunk", true},
{"clementinetree:leaves", false},
{"ebony:trunk", true},
{"ebony:creeper", false},
{"ebony:creeper_leaves", false},
{"ebony:leaves", false},
{"jacaranda:trunk", true},
{"jacaranda:blossom_leaves", false},
{"larch:trunk", true},
{"larch:leaves", false},
{"lemontree:trunk", true},
{"lemontree:leaves", false},
{"mahogany:trunk", true},
{"mahogany:leaves", false},
{"palm:trunk", true},
{"palm:leaves", false},
-- Support growing_cactus
{"growing_cactus:sprout", true},
{"growing_cactus:branch_sprout_vertical", true},
{"growing_cactus:branch_sprout_vertical_fixed", true},
{"growing_cactus:branch_sprout_xp", true},
{"growing_cactus:branch_sprout_xm", true},
{"growing_cactus:branch_sprout_zp", true},
{"growing_cactus:branch_sprout_zm", true},
{"growing_cactus:trunk", true},
{"growing_cactus:branch_trunk", true},
{"growing_cactus:branch", true},
{"growing_cactus:branch_xp", true},
{"growing_cactus:branch_xm", true},
{"growing_cactus:branch_zp", true},
{"growing_cactus:branch_zm", true},
{"growing_cactus:branch_zz", true},
{"growing_cactus:branch_xx", true},
-- Support farming_plus
{"farming_plus:banana_leaves", false},
{"farming_plus:banana", false},
{"farming_plus:cocoa_leaves", false},
{"farming_plus:cocoa", false},
-- Support nature
{"nature:blossom", false},
-- Support snow
{"snow:needles", false},
{"snow:needles_decorated", false},
{"snow:star", false},
-- Support vines (also generated by moretrees if available)
{"vines:vines", false},
{"trunks:moss", false},
{"trunks:moss_fungus", false},
{"trunks:treeroot", false},
}
if chainsaw_leaves then
timber_nodenames["default:acacia_leaves"] = true
timber_nodenames["default:aspen_leaves"] = true
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
if minetest.get_modpath("technic_worldgen") or
minetest.get_modpath("moretrees") then
timber_nodenames["moretrees:rubber_tree_trunk_empty"] = true
timber_nodenames["moretrees:rubber_tree_trunk"] = true
if chainsaw_leaves then
timber_nodenames["moretrees:rubber_tree_leaves"] = true
end
end
-- 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:beech_trunk"] = true
timber_nodenames["moretrees:birch_trunk"] = true
timber_nodenames["moretrees:fir_trunk"] = true
timber_nodenames["moretrees:oak_trunk"] = true
timber_nodenames["moretrees:palm_trunk"] = true
timber_nodenames["moretrees:pine_trunk"] = true
timber_nodenames["moretrees:sequoia_trunk"] = true
timber_nodenames["moretrees:spruce_trunk"] = true
timber_nodenames["moretrees:willow_trunk"] = true
timber_nodenames["moretrees:jungletree_trunk"] = true
timber_nodenames["moretrees:poplar_trunk"] = 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
timber_nodenames["moretrees:fir_leaves_bright"] = true
timber_nodenames["moretrees:sequoia_leaves"] = true
timber_nodenames["moretrees:birch_leaves"] = true
timber_nodenames["moretrees:birch_leaves"] = true
timber_nodenames["moretrees:palm_leaves"] = true
timber_nodenames["moretrees:spruce_leaves"] = true
timber_nodenames["moretrees:spruce_leaves"] = true
timber_nodenames["moretrees:pine_leaves"] = true
timber_nodenames["moretrees:willow_leaves"] = true
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
timber_nodenames["moretrees:poplar_leaves"] = true
end
end
-- Support growing_trees
if minetest.get_modpath("growing_trees") then
timber_nodenames["growing_trees:trunk"] = true
timber_nodenames["growing_trees:medium_trunk"] = true
timber_nodenames["growing_trees:big_trunk"] = true
timber_nodenames["growing_trees:trunk_top"] = true
timber_nodenames["growing_trees:trunk_sprout"] = true
timber_nodenames["growing_trees:branch_sprout"] = true
timber_nodenames["growing_trees:branch"] = true
timber_nodenames["growing_trees:branch_xmzm"] = true
timber_nodenames["growing_trees:branch_xpzm"] = true
timber_nodenames["growing_trees:branch_xmzp"] = true
timber_nodenames["growing_trees:branch_xpzp"] = true
timber_nodenames["growing_trees:branch_zz"] = true
timber_nodenames["growing_trees:branch_xx"] = true
if chainsaw_leaves then
timber_nodenames["growing_trees:leaves"] = true
end
end
-- Support growing_cactus
if minetest.get_modpath("growing_cactus") then
timber_nodenames["growing_cactus:sprout"] = true
timber_nodenames["growing_cactus:branch_sprout_vertical"] = true
timber_nodenames["growing_cactus:branch_sprout_vertical_fixed"] = true
timber_nodenames["growing_cactus:branch_sprout_xp"] = true
timber_nodenames["growing_cactus:branch_sprout_xm"] = true
timber_nodenames["growing_cactus:branch_sprout_zp"] = true
timber_nodenames["growing_cactus:branch_sprout_zm"] = true
timber_nodenames["growing_cactus:trunk"] = true
timber_nodenames["growing_cactus:branch_trunk"] = true
timber_nodenames["growing_cactus:branch"] = true
timber_nodenames["growing_cactus:branch_xp"] = true
timber_nodenames["growing_cactus:branch_xm"] = true
timber_nodenames["growing_cactus:branch_zp"] = true
timber_nodenames["growing_cactus:branch_zm"] = true
timber_nodenames["growing_cactus:branch_zz"] = true
timber_nodenames["growing_cactus:branch_xx"] = true
end
-- Support farming_plus
if minetest.get_modpath("farming_plus") then
if chainsaw_leaves then
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
local timber_nodenames = {}
for _, node in pairs(nodes) do
if chainsaw_leaves or node[2] then
timber_nodenames[node[1]] = true
end
end