lnjX / Minetest_TNG

The NeXt Game for the MGE [minetest_tng]
https://gamerbude.github.io/tng
GNU General Public License v3.0
10 stars 5 forks source link

Tree API: Automatic creation of growing functions (with schematic) #19

Closed lnjX closed 8 years ago

lnjX commented 8 years ago

Now you can give default.register_tree a schematic and it creates a function for it.

Here are some examples:

default.register_tree("default:apple_tree", {
    schematic = core.get_modpath("default") .. "/schematics/apple_tree_from_sapling.mts",
    schematic_size = {x = 2, y = 1, z = 2},
    sapling = {
        growing_type = "schematic_and_function",
        mgv6_grow = function(pos)
            if not default.can_grow() then
                return false
            end

            return default.grow_apple_tree(pos, math.random(1, 4) == 1)
        end,
    }
})

default.register_tree("default:acacia", {
    schematic = core.get_modpath("default") .. "/schematics/acacia_tree_from_sapling.mts",
    schematic_size = {x = 2, y = 1, z = 2},
    sapling = {
        growing_type = "schematic",
    }
})
lnjX commented 8 years ago

@JBBgameich If you don't have any improvements, you can merge it.