----------------------------------------------------------------------------------------------- -- Ferns - Tree Fern 0.1.1 ----------------------------------------------------------------------------------------------- -- by Mossmanikin -- Contains code from: biome_lib -- Looked at code from: default , trees ----------------------------------------------------------------------------------------------- abstract_ferns.grow_tree_fern = function(pos) local pos_aux = {x = pos.x, y = pos.y + 1, z = pos.z} local name = minetest.get_node(pos_aux).name if name ~= "air" and name ~= "ferns:sapling_tree_fern" and name ~= "default:junglegrass" then return end local size = math.random(1, 4) + math.random(1, 4) if (size > 5) then size = 10 - size end size = size + 1 local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)] local i = 1 local brk = false while (i < size) do pos_aux.y = pos.y + i name = minetest.get_node(pos_aux).name if not (name == "air" or (i == 1 and name == "ferns:sapling_tree_fern")) then brk = true break end minetest.swap_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" }) i = i + 1 end if not brk then minetest.swap_node({x = pos.x, y = pos.y + i - 1, z = pos.z}, { name = crown }) end end ----------------------------------------------------------------------------------------------- -- TREE FERN LEAVES ----------------------------------------------------------------------------------------------- -- TODO: Both of these nodes look the same? minetest.register_node("ferns:tree_fern_leaves", { description = "Tree Fern Crown (Dicksonia)", drawtype = "plantlike", visual_scale = math.sqrt(8), paramtype = "light", paramtype2 = "facedir", --tiles = {"[combine:32x32:0,0=top_left.png:0,16=bottom_left.png:16,0=top_right.png:16,16=bottom_right.png"}, tiles = {"ferns_fern_tree.png"}, inventory_image = "ferns_fern_tree_inv.png", walkable = false, groups = {snappy=3,flammable=2,attached_node=1}, drop = { max_items = 2, items = { { -- occasionally, drop a second sapling instead of leaves -- (extra saplings can also be obtained by replanting and -- reharvesting leaves) items = {"ferns:sapling_tree_fern"}, rarity = 10, }, { items = {"ferns:sapling_tree_fern"}, }, { items = {"ferns:tree_fern_leaves"}, } } }, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16}, }, }) minetest.register_node("ferns:tree_fern_leaves_02", { drawtype = "plantlike", visual_scale = math.sqrt(8), paramtype = "light", tiles = {"ferns_fern_big.png"}, walkable = false, groups = {snappy=3,flammable=2,attached_node=1,not_in_creative_inventory=1}, drop = { max_items = 2, items = { { -- occasionally, drop a second sapling instead of leaves -- (extra saplings can also be obtained by replanting and -- reharvesting leaves) items = {"ferns:sapling_tree_fern"}, rarity = 10, }, { items = {"ferns:sapling_tree_fern"}, }, { items = {"ferns:tree_fern_leaves"}, } } }, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16}, }, }) ----------------------------------------------------------------------------------------------- -- FERN TRUNK ----------------------------------------------------------------------------------------------- minetest.register_node("ferns:fern_trunk", { description = "Fern Trunk (Dicksonia)", drawtype = "nodebox", paramtype = "light", tiles = { "ferns_fern_trunk_top.png", "ferns_fern_trunk_top.png", "ferns_fern_trunk.png" }, node_box = { type = "fixed", fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}, }, selection_box = { type = "fixed", fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, }, groups = {tree=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, sounds = default.node_sound_wood_defaults(), after_destruct = function(pos,oldnode) local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) if node.name == "ferns:fern_trunk" then minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z}) minetest.add_item(pos,"ferns:fern_trunk") end end, }) ----------------------------------------------------------------------------------------------- -- TREE FERN SAPLING ----------------------------------------------------------------------------------------------- minetest.register_node("ferns:sapling_tree_fern", { description = "Tree Fern Sapling (Dicksonia)", drawtype = "plantlike", paramtype = "light", paramtype2 = "facedir", tiles = {"ferns_sapling_tree_fern.png"}, inventory_image = "ferns_sapling_tree_fern.png", walkable = false, groups = {snappy=3,flammable=2,flora=1,attached_node=1}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16}, }, })