minetest-mods / technic

Technic mod for Minetest
Other
145 stars 155 forks source link

Add cool_trees support to the chainsaw #511

Closed coil0 closed 5 years ago

coil0 commented 5 years ago

This adds the nodes from the cool_trees modpack.

SmallJoker commented 5 years ago

That's quite repetitive. How about making it dynamic so that adding more mods will be even easier?

local nodes = {
    -- "node:name", is_leaf
    { "bamboo:trunk",  false },
    { "bamboo:leaves", true },
    { "birch:trunk",   false },
    { "birch:leaves",  true },
    -- ...
}

for i, d in ipairs(nodes) do
    if not d[2] or chainsaw_leaves then
        local mod_name = d[1]:match("^([^:]+)")
        if minetest.get_modpath(mod_name) then
            timber_nodenames[d[1]] = true
        end
    end
end
coil0 commented 5 years ago

We can make it still easier by not checking if the mod is installed, which seems unnecessary. The first part of the node name doesn't always match the mod that registers the node anyway.