From 9681cada82534c09b413523ee2f7f60cf94f518a Mon Sep 17 00:00:00 2001 From: yzelast Date: Thu, 5 Jan 2017 15:04:33 -0300 Subject: [PATCH] trees now are now independent --- trees/acacia/abms.lua | 45 +++++ trees/acacia/functions.lua | 195 +++++++++++++++++++++ trees/acacia/itens.lua | 54 ++++++ trees/acacia/leaves.lua | 79 +++++++++ trees/acacia/schems/acacia_tree.mts | Bin 0 -> 159 bytes trees/acacia/schems/large_acacia_tree.mts | Bin 0 -> 341 bytes trees/acacia/schems/medium_acacia_tree.mts | Bin 0 -> 271 bytes trees/acacia/schems/small_acacia_tree.mts | Bin 0 -> 179 bytes trees/acacia/trunks.lua | 191 ++++++++++++++++++++ trees/apple/abms.lua | 43 +++++ trees/apple/functions.lua | 116 ++++++++++++ trees/apple/itens.lua | 53 ++++++ trees/apple/leaves.lua | 79 +++++++++ trees/apple/schems/large_tree.mts | Bin 0 -> 134 bytes trees/apple/schems/medium_tree.mts | Bin 0 -> 194 bytes trees/apple/schems/small_tree.mts | Bin 0 -> 82 bytes trees/apple/schems/tree.mts | Bin 0 -> 149 bytes trees/apple/trunks.lua | 128 ++++++++++++++ trees/aspen/abms.lua | 45 +++++ trees/aspen/functions.lua | 155 ++++++++++++++++ trees/aspen/itens.lua | 54 ++++++ trees/aspen/leaves.lua | 79 +++++++++ trees/aspen/schems/aspen_tree.mts | Bin 0 -> 171 bytes trees/aspen/schems/large_aspen_tree.mts | Bin 0 -> 289 bytes trees/aspen/schems/medium_aspen_tree.mts | Bin 0 -> 244 bytes trees/aspen/schems/small_aspen_tree.mts | Bin 0 -> 224 bytes trees/aspen/trunks.lua | 131 ++++++++++++++ trees/jungle/abms.lua | 43 +++++ trees/jungle/functions.lua | 160 +++++++++++++++++ trees/jungle/itens.lua | 64 +++++++ trees/jungle/leaves.lua | 79 +++++++++ trees/jungle/schems/jungle_tree.mts | Bin 0 -> 211 bytes trees/jungle/schems/large_jungle_tree.mts | Bin 0 -> 212 bytes trees/jungle/schems/medium_jungle_tree.mts | Bin 0 -> 313 bytes trees/jungle/schems/small_jungle_tree.mts | Bin 0 -> 219 bytes trees/jungle/trunks.lua | 128 ++++++++++++++ trees/pine/abms.lua | 43 +++++ trees/pine/functions.lua | 160 +++++++++++++++++ trees/pine/itens.lua | 53 ++++++ trees/pine/leaves.lua | 154 ++++++++++++++++ trees/pine/schems/large_pine_tree.mts | Bin 0 -> 331 bytes trees/pine/schems/medium_pine_tree.mts | Bin 0 -> 320 bytes trees/pine/schems/pine_tree.mts | Bin 0 -> 163 bytes trees/pine/schems/small_pine_tree.mts | Bin 0 -> 303 bytes trees/pine/trunks.lua | 128 ++++++++++++++ 45 files changed, 2459 insertions(+) create mode 100644 trees/acacia/abms.lua create mode 100644 trees/acacia/functions.lua create mode 100644 trees/acacia/itens.lua create mode 100644 trees/acacia/leaves.lua create mode 100644 trees/acacia/schems/acacia_tree.mts create mode 100644 trees/acacia/schems/large_acacia_tree.mts create mode 100644 trees/acacia/schems/medium_acacia_tree.mts create mode 100644 trees/acacia/schems/small_acacia_tree.mts create mode 100644 trees/acacia/trunks.lua create mode 100644 trees/apple/abms.lua create mode 100644 trees/apple/functions.lua create mode 100644 trees/apple/itens.lua create mode 100644 trees/apple/leaves.lua create mode 100644 trees/apple/schems/large_tree.mts create mode 100644 trees/apple/schems/medium_tree.mts create mode 100644 trees/apple/schems/small_tree.mts create mode 100644 trees/apple/schems/tree.mts create mode 100644 trees/apple/trunks.lua create mode 100644 trees/aspen/abms.lua create mode 100644 trees/aspen/functions.lua create mode 100644 trees/aspen/itens.lua create mode 100644 trees/aspen/leaves.lua create mode 100644 trees/aspen/schems/aspen_tree.mts create mode 100644 trees/aspen/schems/large_aspen_tree.mts create mode 100644 trees/aspen/schems/medium_aspen_tree.mts create mode 100644 trees/aspen/schems/small_aspen_tree.mts create mode 100644 trees/aspen/trunks.lua create mode 100644 trees/jungle/abms.lua create mode 100644 trees/jungle/functions.lua create mode 100644 trees/jungle/itens.lua create mode 100644 trees/jungle/leaves.lua create mode 100644 trees/jungle/schems/jungle_tree.mts create mode 100644 trees/jungle/schems/large_jungle_tree.mts create mode 100644 trees/jungle/schems/medium_jungle_tree.mts create mode 100644 trees/jungle/schems/small_jungle_tree.mts create mode 100644 trees/jungle/trunks.lua create mode 100644 trees/pine/abms.lua create mode 100644 trees/pine/functions.lua create mode 100644 trees/pine/itens.lua create mode 100644 trees/pine/leaves.lua create mode 100644 trees/pine/schems/large_pine_tree.mts create mode 100644 trees/pine/schems/medium_pine_tree.mts create mode 100644 trees/pine/schems/pine_tree.mts create mode 100644 trees/pine/schems/small_pine_tree.mts create mode 100644 trees/pine/trunks.lua diff --git a/trees/acacia/abms.lua b/trees/acacia/abms.lua new file mode 100644 index 0000000..7c074b2 --- /dev/null +++ b/trees/acacia/abms.lua @@ -0,0 +1,45 @@ +minetest.register_abm { + nodenames = "default:acacia_sapling", + chance = 1, + interval = 2, + action = function(pos) + if acacia_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["acacia"] * 1) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_small_acacia_tree", + chance = 1, + interval = 4, + + action = function(pos) + if acacia_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["acacia"] * 2) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_medium_acacia_tree", + chance = 1, + interval = 6, + action = function(pos) + if acacia_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["acacia"] * 3) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_large_acacia_tree", + chance = 1, + interval = 8, + action = function(pos) + if acacia_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["acacia"] * 4) + end + end +} + diff --git a/trees/acacia/functions.lua b/trees/acacia/functions.lua new file mode 100644 index 0000000..8a0a224 --- /dev/null +++ b/trees/acacia/functions.lua @@ -0,0 +1,195 @@ +local function node_exist(table,node) + for key,value in pairs(table) do + if value == node.name then + return true + end + end +return false +end + +local function fix_trunks(pos,size) + if size == 1 then + for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 2 then + for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 3 then + for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 4 then + for i = 0,2 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + end +end + +local function fix_leaves(pos,radius) + +local leaves = { + "real_trees:small_acacia_leaves", + "real_trees:corner_acacia_leaves", + "real_trees:wide_acacia_leaves", + "real_trees:acacia_leaf_slab", + "real_trees:corner_acacia_tree", + "real_trees:t_corner_acacia_tree", + "default:acacia_leaves" + } + + if radius == 1 then + + local positions = { + {x = pos.x - 1,y = pos.y,z = pos.z - 1}, + {x = pos.x - 1,y = pos.y,z = pos.z}, + {x = pos.x - 1,y = pos.y,z = pos.z + 1}, + {x = pos.x,y = pos.y,z = pos.z - 1}, + {x = pos.x,y = pos.y,z = pos.z + 1}, + {x = pos.x + 1,y = pos.y,z = pos.z - 1}, + {x = pos.x + 1,y = pos.y,z = pos.z}, + {x = pos.x + 1,y = pos.y,z = pos.z + 1} + } + + for key,value in pairs(positions) do + if node_exist(leaves,minetest.get_node(value)) then + minetest.set_node(value,{name = "air"}) + end + end + +elseif radius == 2 then + +local positions = { + {x = pos.x - 2,y = pos.y,z = pos.z - 2}, + {x = pos.x - 2,y = pos.y,z = pos.z - 1}, + {x = pos.x - 2,y = pos.y,z = pos.z}, + {x = pos.x - 2,y = pos.y,z = pos.z + 1}, + {x = pos.x - 2,y = pos.y,z = pos.z + 2}, + + {x = pos.x - 1,y = pos.y,z = pos.z - 2}, + {x = pos.x,y = pos.y,z = pos.z - 2}, + {x = pos.x + 1,y = pos.y,z = pos.z - 2}, + {x = pos.x - 1,y = pos.y,z = pos.z + 2}, + {x = pos.x,y = pos.y,z = pos.z + 2}, + {x = pos.x + 1,y = pos.y,z = pos.z + 2}, + + {x = pos.x + 2,y = pos.y,z = pos.z - 2}, + {x = pos.x + 2,y = pos.y,z = pos.z - 1}, + {x = pos.x + 2,y = pos.y,z = pos.z}, + {x = pos.x + 2,y = pos.y,z = pos.z + 1}, + {x = pos.x + 2,y = pos.y,z = pos.z + 2} + } + + for key,value in pairs(positions) do + if node_exist(leaves,minetest.get_node(value)) then + minetest.set_node(value,{name = "air"}) + end + end + +elseif radius == 3 then + +local positions = { + {x = pos.x - 3,y = pos.y,z = pos.z - 3}, + {x = pos.x - 3,y = pos.y,z = pos.z - 2}, + {x = pos.x - 3,y = pos.y,z = pos.z - 1}, + {x = pos.x - 3,y = pos.y,z = pos.z}, + {x = pos.x - 3,y = pos.y,z = pos.z + 1}, + {x = pos.x - 3,y = pos.y,z = pos.z + 2}, + {x = pos.x - 3,y = pos.y,z = pos.z + 3}, + + {x = pos.x - 2,y = pos.y,z = pos.z - 3}, + {x = pos.x - 1,y = pos.y,z = pos.z - 3}, + {x = pos.x,y = pos.y,z = pos.z - 3}, + {x = pos.x + 1,y = pos.y,z = pos.z - 3}, + {x = pos.x + 2,y = pos.y,z = pos.z - 3}, + + {x = pos.x - 2,y = pos.y,z = pos.z + 3}, + {x = pos.x - 1,y = pos.y,z = pos.z + 3}, + {x = pos.x,y = pos.y,z = pos.z + 3}, + {x = pos.x + 1,y = pos.y,z = pos.z + 3}, + {x = pos.x + 2,y = pos.y,z = pos.z + 3}, + + {x = pos.x + 3,y = pos.y,z = pos.z - 3}, + {x = pos.x + 3,y = pos.y,z = pos.z - 2}, + {x = pos.x + 3,y = pos.y,z = pos.z - 1}, + {x = pos.x + 3,y = pos.y,z = pos.z}, + {x = pos.x + 3,y = pos.y,z = pos.z + 1}, + {x = pos.x + 3,y = pos.y,z = pos.z + 2}, + {x = pos.x + 3,y = pos.y,z = pos.z + 3} + } + + for key,value in pairs(positions) do + if node_exist(leaves,minetest.get_node(value)) then + minetest.set_node(value,{name = "air"}) + end + end + +end +end + +local function fix_everything(pos,size) + if size == 1 then + fix_trunks(pos,1) + elseif size == 2 then + fix_trunks(pos,2) + fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z},1) + elseif size == 3 then + fix_trunks(pos,3) + fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},2) + elseif size == 4 then + fix_trunks(pos,4) + fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},2) + fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},3) + fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},2) + fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},3) + end +end + +local function can_grow(pos,size) + + local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"} + local under = {x = pos.x,y = pos.y - 1,z = pos.z} + + if size == 1 then + if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + elseif size == 2 then + if minetest.get_node_light({x = pos.x,y = pos.y + 2,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + elseif size == 3 then + if minetest.get_node_light({x = pos.x,y = pos.y + 3,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + elseif size == 4 then + if minetest.get_node_light({x = pos.x,y = pos.y + 4,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + end +end + +function acacia_growth(pos,size,action) + if action == 1 then + if can_grow(pos,size) then return true else return false end +elseif action == 2 then + if size == 1 then + fix_everything(pos,1) + minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/acacia/schems/small_acacia_tree.mts","0",nil,false) +elseif size == 2 then + fix_everything(pos,2) + minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/acacia/schems/medium_acacia_tree.mts","0",nil,false) +elseif size == 3 then + fix_everything(pos,3) + minetest.place_schematic({x = pos.x - 3,y = pos.y,z = pos.z - 3},minetest.get_modpath("real_trees").."/trees/acacia/schems/large_acacia_tree.mts","random",nil,false) +elseif size == 4 then + fix_everything(pos,4) + minetest.place_schematic({x = pos.x - 4,y = pos.y,z = pos.z - 4},minetest.get_modpath("real_trees").."/trees/acacia/schems/acacia_tree.mts","random",nil,false) + end + end +end diff --git a/trees/acacia/itens.lua b/trees/acacia/itens.lua new file mode 100644 index 0000000..264199b --- /dev/null +++ b/trees/acacia/itens.lua @@ -0,0 +1,54 @@ +minetest.register_craft({ + type = "shapeless", + output = "default:acacia_wood 2", + recipe = {"real_trees:small_acacia_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:acacia_wood 4", + recipe = {"real_trees:medium_acacia_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:acacia_wood 6", + recipe = {"real_trees:large_acacia_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:acacia_wood 8", + recipe = {"default:acacia_tree"}, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:small_acacia_tree", + burntime = 8.5, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:medium_acacia_tree", + burntime = 17, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:large_acacia_tree", + burntime = 25.5, +}) + +minetest.override_item("default:acacia_sapling",{ + on_timer = function(pos) + acacia_growth(pos,1,2) + end, + + on_construct = function(pos) + if acacia_growth(pos,1,1) then + minetest.get_node_timer(pos):start(growth_time["acacia"] * 1) + end + end +}) + diff --git a/trees/acacia/leaves.lua b/trees/acacia/leaves.lua new file mode 100644 index 0000000..6321106 --- /dev/null +++ b/trees/acacia/leaves.lua @@ -0,0 +1,79 @@ +minetest.register_node("real_trees:small_acacia_leaves", { + description = "Small Acacia Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:acacia_sapling"},rarity = 160}, + {items = {"real_trees:small_acacia_leaves"}} + } + }, + + tiles = {"default_acacia_leaves.png"}, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}} +}) + +minetest.register_node("real_trees:corner_acacia_leaves", { + description = "Corner Acacia Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {'default:acacia_sapling'},rarity = 160}, + {items = {'real_trees:corner_acacia_leaves'}} + } + }, + + tiles = { "default_acacia_leaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:wide_acacia_leaves", { + description = "Wide Acacia Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:acacia_sapling"},rarity = 80}, + {items = {"real_trees:wide_acacia_leaves"}} + } + }, + + tiles = { "default_acacia_leaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.5,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:acacia_leaf_slab", { + description = "Acacia Leaf Slab", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:acacia_sapling"},rarity = 40}, + {items = {"real_trees:acacia_leaf_slab"}} + } + }, + + tiles = { "default_acacia_leaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}} +}) diff --git a/trees/acacia/schems/acacia_tree.mts b/trees/acacia/schems/acacia_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..8137a5322c81d86b0bd815a8409d4a3434db3362 GIT binary patch literal 159 zcmeYb3HD`RVc=w7XW*=d00w3T=ETe*2GNw%w8YY!605}I#N^Dx_?*I#GLq&qSVx4tHk8QF$u-a#Q5CQl+4mxn6V(2 zpxB8iT`?y);Q*6_5yrxJTp5kbYH$#^@=e>dd5VZ d+YH1>oYHlfd!U7Bo>rSaI1^@?cV$%Qs literal 0 HcmV?d00001 diff --git a/trees/acacia/schems/small_acacia_tree.mts b/trees/acacia/schems/small_acacia_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..348852b5896d248b9e2dec8617215e4f77eca135 GIT binary patch literal 179 zcmeYb3HD`RVPIxpVqmVXXJBPuPRuM~kS|J2%!w~4N=+@cO3p9JOD&2|OioPBOpMP- zO)N_-W{^cvP@b8RiY6_GB%K&voST@F15*JqltDBlH7&6;r^E`y)QUOD2@K3`Y-$Q= h2?=aTYHVT(ZbIviGbC6}h;nl?IC+GH;TIPtKLBmCJ8%F1 literal 0 HcmV?d00001 diff --git a/trees/acacia/trunks.lua b/trees/acacia/trunks.lua new file mode 100644 index 0000000..e382598 --- /dev/null +++ b/trees/acacia/trunks.lua @@ -0,0 +1,191 @@ +minetest.register_node("real_trees:corner_acacia_tree", { + description = "Corner Acacia Trunk", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:small_acacia_tree", + tiles = { + "real_trees_corner_acacia_tree_top.png", + "real_trees_corner_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:t_corner_acacia_tree", { + description = "T Corner Acacia Trunk", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:medium_acacia_tree", + tiles = { + "real_trees_corner_acacia_tree_top.png", + "real_trees_corner_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0.5,0.5}}} +}) + +minetest.register_node("real_trees:small_acacia_tree", { + description = "Small Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:small_acacia_tree", + tiles = { + "real_trees_small_acacia_tree_top.png", + "real_trees_small_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}} +}) + +minetest.register_node("real_trees:medium_acacia_tree", { + description = "Medium Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:medium_acacia_tree", + tiles = { + "real_trees_medium_acacia_tree_top.png", + "real_trees_medium_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}} +}) + +minetest.register_node("real_trees:large_acacia_tree", { + description = "Large Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:large_acacia_tree", + tiles = { + "real_trees_large_acacia_tree_top.png", + "real_trees_large_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}} +}) + +minetest.register_node("real_trees:h_large_acacia_tree", { + description = "H Large Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:large_acacia_tree", + tiles = { + "default_acacia_tree_top.png", + "real_trees_large_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + node_box = {type = "fixed",fixed = { + {-0.375,-0.5,0.375,0.375,0.5,-0.375}, + {-0.5,0,-0.5,0.5,0.5,0.5} + } + } +}) + +minetest.register_node("real_trees:a_small_acacia_tree", { + description = "A Small Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:small_acacia_tree", + tiles = { + "real_trees_small_acacia_tree_top.png", + "real_trees_small_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}, + on_timer = function(pos,elapsed) + acacia_growth(pos,2,2) + end, +}) + +minetest.register_node("real_trees:a_medium_acacia_tree", { + description = "A Medium Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:medium_acacia_tree", + tiles = { + "real_trees_medium_acacia_tree_top.png", + "real_trees_medium_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}, + on_timer = function(pos,elapsed) + acacia_growth(pos,3,2) + end, +}) + +minetest.register_node("real_trees:a_large_acacia_tree", { + description = "A Large Acacia Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:large_jungle_tree", + tiles = { + "real_trees_large_acacia_tree_top.png", + "real_trees_large_acacia_tree_top.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + "default_acacia_tree.png", + }, + + node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}, + on_timer = function(pos,elapsed) + acacia_growth(pos,4,2) + end, +}) diff --git a/trees/apple/abms.lua b/trees/apple/abms.lua new file mode 100644 index 0000000..0a40921 --- /dev/null +++ b/trees/apple/abms.lua @@ -0,0 +1,43 @@ +minetest.register_abm { + nodenames = "default:sapling", + chance = 1, + interval = 2, + action = function(pos) + if apple_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["apple"] * 1) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_small_tree", + chance = 1, + interval = 4, + action = function(pos) + if apple_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["apple"] * 2) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_medium_tree", + chance = 1, + interval = 6, + action = function(pos) + if apple_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["apple"] * 3) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_large_tree", + chance = 1, + interval = 8, + action = function(pos) + if apple_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["apple"] * 4) + end + end +} diff --git a/trees/apple/functions.lua b/trees/apple/functions.lua new file mode 100644 index 0000000..d747f88 --- /dev/null +++ b/trees/apple/functions.lua @@ -0,0 +1,116 @@ +local function node_exist(table,node) + for key,value in pairs(table) do + if value == node.name then + return true + end + end +return false +end + +local function fix_trunks(pos,size) + if size == 1 then + for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 2 then + for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 3 then + for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 4 then + for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + end +end + +local function fix_leaves(pos) + +local leaves = { + "real_trees:small_leaves", + "real_trees:corner_leaves", + "real_trees:wide_leaves", + "real_trees:leaf_slab", + "default:leaves", + } + +local positions = { + {x = pos.x - 1,y = pos.y,z = pos.z - 1}, + {x = pos.x - 1,y = pos.y,z = pos.z}, + {x = pos.x - 1,y = pos.y,z = pos.z + 1}, + {x = pos.x,y = pos.y,z = pos.z - 1}, + {x = pos.x,y = pos.y,z = pos.z + 1}, + {x = pos.x + 1,y = pos.y,z = pos.z - 1}, + {x = pos.x + 1,y = pos.y,z = pos.z}, + {x = pos.x + 1,y = pos.y,z = pos.z + 1} + } + + for key,value in pairs(positions) do + if node_exist(leaves,minetest.get_node(value)) then + minetest.set_node(value,{name = "air"}) + end + end +end + +local function fix_everything(pos,size) + if size == 1 then + fix_trunks(pos,1) + elseif size == 2 then + fix_trunks(pos,2) + elseif size == 3 then + fix_trunks(pos,3) + fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z}) + fix_leaves({x = pos.x,y = pos.y + 2,z = pos.z}) + elseif size == 4 then + fix_trunks(pos,4) + fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z}) + fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z}) + end +end + +local function can_grow(pos,size) + + local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"} + local under = {x = pos.x,y = pos.y - 1,z = pos.z} + + if size == 1 then + if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end +elseif size == 2 then + if minetest.get_node_light({x = pos.x,y = pos.y + 3,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end +elseif size == 3 then + if minetest.get_node_light({x = pos.x,y = pos.y + 5,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end +elseif size == 4 then + if minetest.get_node_light({x = pos.x,y = pos.y + 8,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + end +end + +function apple_growth(pos,size,action) + if action == 1 then + if can_grow(pos,size) then return true else return false end +elseif action == 2 then + if size == 1 then + fix_everything(pos,1) + minetest.place_schematic(pos,minetest.get_modpath("real_trees").."/trees/apple/schems/small_tree.mts","0",nil,false) +elseif size == 2 then + fix_everything(pos,2) + minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/apple/schems/medium_tree.mts","0",nil,false) +elseif size == 3 then + fix_everything(pos,3) + minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/apple/schems/large_tree.mts","0",nil,false) +elseif size == 4 then + fix_everything(pos,4) + minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/apple/schems/tree.mts","random",nil,false) + end + end +end diff --git a/trees/apple/itens.lua b/trees/apple/itens.lua new file mode 100644 index 0000000..c1aa9b9 --- /dev/null +++ b/trees/apple/itens.lua @@ -0,0 +1,53 @@ +minetest.register_craft({ + type = "shapeless", + output = "default:wood 2", + recipe = {"real_trees:small_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:wood 4", + recipe = {"real_trees:medium_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:wood 6", + recipe = {"real_trees:large_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:wood 8", + recipe = {"default:tree"}, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:small_tree", + burntime = 7.5, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:medium_tree", + burntime = 15, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:large_tree", + burntime = 22.5, +}) + +minetest.override_item("default:sapling",{ + on_timer = function(pos) + apple_growth(pos,1,2) + end, + + on_construct = function(pos) + if apple_growth(pos,1,1) then + minetest.get_node_timer(pos):start(growth_time["apple"] * 1) + end + end +}) diff --git a/trees/apple/leaves.lua b/trees/apple/leaves.lua new file mode 100644 index 0000000..6d176ec --- /dev/null +++ b/trees/apple/leaves.lua @@ -0,0 +1,79 @@ +minetest.register_node("real_trees:small_leaves", { + description = "Small Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:sapling"},rarity = 160}, + {items = {'real_trees:small_leaves'}} + } + }, + + tiles = {"default_leaves.png"}, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed", fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}} +}) + +minetest.register_node("real_trees:corner_leaves", { + description = "Corner Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:sapling"},rarity = 160}, + items = {"real_trees:corner_leaves"} + } + }, + + tiles = {"default_leaves.png"}, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed", fixed = {{0,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:wide_leaves", { + description = "Wide Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:sapling"},rarity = 80}, + {items = {"real_trees:wide_leaves"}} + } + }, + + tiles = {"default_leaves.png"}, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed", fixed = {{-0.5,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:leaf_slab", { + description = "Leaf Slab", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:sapling"},rarity = 40}, + {items = {"real_trees:pine_needle_slab"}} + } + }, + + tiles = {"default_leaves.png"}, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}} +}) diff --git a/trees/apple/schems/large_tree.mts b/trees/apple/schems/large_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..39bc22803a6edcc41228a531ff1adefae6b99441 GIT binary patch literal 134 zcmeYb3HD`RVPIxpWniuc0T3rKvxtE&B{eOvG^fNWCpEDwwU|M?C^a!BzN9EMwb&{# zJ}0p#Jr&Gj5Ji$e2v^KWPB_5OlW>CJ7!Qw6!X!yQBPLgghglz9tW{@K;7M>XoFS-k NphJzD;rC^+3IG}CEt&uT literal 0 HcmV?d00001 diff --git a/trees/apple/schems/medium_tree.mts b/trees/apple/schems/medium_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..a45fcc63a07112a26f2865776178e5ad73f05994 GIT binary patch literal 194 zcmeYb3HD`RVPFQq`uchXHU{Rz%pwMfqSVBk_>!X3)MBgT{GzW1*v)QIjM2{-Lo3EIt!NjvkESnOZ86AAK5H literal 0 HcmV?d00001 diff --git a/trees/aspen/schems/large_aspen_tree.mts b/trees/aspen/schems/large_aspen_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..a2fe00504719afc27ffaaf71420d9a2bfded8784 GIT binary patch literal 289 zcmeYb3HD`RVPIz9U|_C?0tR*l=ETe*2Dzft#GLq&qSVx4tK|Hmywsxj#NvX~y!f2d z#In?41{oyz^30S}R9TUf)U?FXoDwS(JyJ+|;1X%^#W{&d46?{_@i~b_=`bTfZeWl` zl17)Tn6tL`AXkF{kMrbPS2?XUUVQ)c`k3$YgOd}y( zYV&4Ji2bs9`>X!%-{)W1|8&o!IYojC^|y=Vusq+|@no~V;H=60N@w}DPga!z0AA5{ A{{R30 literal 0 HcmV?d00001 diff --git a/trees/aspen/schems/medium_aspen_tree.mts b/trees/aspen/schems/medium_aspen_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..947b598f32f5e04eaf9847fb109668b87ca4046a GIT binary patch literal 244 zcmeYb3HD`RVPIxpV_>ca0}v}Qvxq^iC^a!BzN9EMwb&{-zbG%YC_b^cAT=*OCpEDw zwU|K$NxnQYB^6axBqcR1u{5W|3PlgHnTheasVSMIxlnx|i%`tOkgb@LoN$1lhsP)3 z49`-@#w48t$uNtPEGmv#5eHW}%-|?~b&{#zvxUVDOUa#*4bKiXC^Ty*Gb<}AJGF%R ROqn{de_|&m!=dfcy8+GoS=Imm literal 0 HcmV?d00001 diff --git a/trees/aspen/schems/small_aspen_tree.mts b/trees/aspen/schems/small_aspen_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..e13eea398e173cde763fa0710378d286a9d5b783 GIT binary patch literal 224 zcmeYb3HD`RVPFQq`uchXHU{Rz%pwN4qSVBk_>!X3)MBgT{GzD2plvGq%StQxS_~P8eoE)eEkckY^NYWURQb>|;E7RhOa}tv(<|HRDFuSp- xDYP-BDWoMOFeb6Fh3(LoG^^?kgU0EDicEoOCl2tNbvI7!<@aD>FgnG14*++hPPG64 literal 0 HcmV?d00001 diff --git a/trees/aspen/trunks.lua b/trees/aspen/trunks.lua new file mode 100644 index 0000000..af26fbe --- /dev/null +++ b/trees/aspen/trunks.lua @@ -0,0 +1,131 @@ +minetest.register_node("real_trees:small_aspen_tree", { + description = "Small Aspen Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:small_aspen_tree", + tiles = { + "real_trees_small_aspen_tree_top.png", + "real_trees_small_aspen_tree_top.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}} +}) + +minetest.register_node("real_trees:medium_aspen_tree", { + description = "Medium Aspen Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:medium_aspen_tree", + tiles = { + "real_trees_medium_aspen_tree_top.png", + "real_trees_medium_aspen_tree_top.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}} +}) + +minetest.register_node("real_trees:large_aspen_tree", { + description = "Large Aspen Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:large_aspen_tree", + tiles = { + "real_trees_large_aspen_tree_top.png", + "real_trees_large_aspen_tree_top.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}} +}) + +minetest.register_node("real_trees:a_small_aspen_tree", { + description = "A Small Aspen Tree", + drawtype = "nodebox", + paramtype = "light", + drop = "real_trees:small_aspen_tree", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + tiles = { + "real_trees_small_aspen_tree_top.png", + "real_trees_small_aspen_tree_top.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + }, + + on_timer = function(pos,elapsed) + aspen_growth(pos,2,2) + end, + + node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}} +}) + +minetest.register_node("real_trees:a_medium_aspen_tree", { + description = "A Medium Aspen Tree", + drawtype = "nodebox", + paramtype = "light", + drop = "real_trees:medium_aspen_tree", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + tiles = { + "real_trees_medium_aspen_tree_top.png", + "real_trees_medium_aspen_tree_top.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + }, + + on_timer = function(pos,elapsed) + aspen_growth(pos,3,2) + end, + + node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}} +}) + +minetest.register_node("real_trees:a_large_aspen_tree", { + description = "A Large Aspen Tree", + drawtype = "nodebox", + paramtype = "light", + drop = "real_trees:large_aspen_tree", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + tiles = { + "real_trees_large_aspen_tree_top.png", + "real_trees_large_aspen_tree_top.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + "default_aspen_tree.png", + }, + + on_timer = function(pos,elapsed) + aspen_growth(pos,4,2) + end, + + node_box = {type = "fixed",fixed = { {-0.375,-0.5,0.375,0.375,0.5,-0.375}}} +}) diff --git a/trees/jungle/abms.lua b/trees/jungle/abms.lua new file mode 100644 index 0000000..3be3ba2 --- /dev/null +++ b/trees/jungle/abms.lua @@ -0,0 +1,43 @@ +minetest.register_abm { + nodenames = "default:junglesapling", + chance = 1, + interval = 2, + action = function(pos) + if jungle_growth(pos,1,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["jungle"] * 1) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_small_jungle_tree", + chance = 1, + interval = 4, + action = function(pos) + if jungle_growth(pos,2,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["jungle"] * 2) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_medium_jungle_tree", + chance = 1, + interval = 6, + action = function(pos) + if jungle_growth(pos,3,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["jungle"] * 3) + end + end +} + +minetest.register_abm { + nodenames = "real_trees:a_large_jungle_tree", + chance = 1, + interval = 8, + action = function(pos) + if jungle_growth(pos,4,1) and (not minetest.get_node_timer(pos):is_started()) then + minetest.get_node_timer(pos):start(growth_time["jungle"] * 4) + end + end +} diff --git a/trees/jungle/functions.lua b/trees/jungle/functions.lua new file mode 100644 index 0000000..8e6c9ea --- /dev/null +++ b/trees/jungle/functions.lua @@ -0,0 +1,160 @@ +local function node_exist(table,node) + for key,value in pairs(table) do + if value == node.name then + return true + end + end +return false +end + +local function fix_trunks(pos,size) + if size == 1 then + for i = 0,1 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 2 then + for i = 0,4 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 3 then + for i = 0,7 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + elseif size == 4 then + for i = 0,11 do minetest.set_node({x = pos.x,y = pos.y + i,z = pos.z},{name = "air"}) end + end +end + +local function fix_leaves(pos,radius) + +local leaves = { + "real_trees:small_jungle_leaves", + "real_trees:corner_jungle_leaves", + "real_trees:wide_jungle_leaves", + "real_trees:jungle_leaf_slab", + "real_trees:medium_jungle_tree", + "real_trees:large_jungle_tree", + "default:jungleleaves", + } + + if radius == 1 then + + local positions = { + {x = pos.x - 1,y = pos.y,z = pos.z - 1}, + {x = pos.x - 1,y = pos.y,z = pos.z}, + {x = pos.x - 1,y = pos.y,z = pos.z + 1}, + {x = pos.x,y = pos.y,z = pos.z - 1}, + {x = pos.x,y = pos.y,z = pos.z + 1}, + {x = pos.x + 1,y = pos.y,z = pos.z - 1}, + {x = pos.x + 1,y = pos.y,z = pos.z}, + {x = pos.x + 1,y = pos.y,z = pos.z + 1} + } + + for key,value in pairs(positions) do + if node_exist(leaves,minetest.get_node(value)) then + minetest.set_node(value,{name = "air"}) + end + end + +elseif radius == 2 then + +local positions = { + {x = pos.x - 2,y = pos.y,z = pos.z - 2}, + {x = pos.x - 2,y = pos.y,z = pos.z - 1}, + {x = pos.x - 2,y = pos.y,z = pos.z}, + {x = pos.x - 2,y = pos.y,z = pos.z + 1}, + {x = pos.x - 2,y = pos.y,z = pos.z + 2}, + + {x = pos.x - 1,y = pos.y,z = pos.z - 2}, + {x = pos.x,y = pos.y,z = pos.z - 2}, + {x = pos.x + 1,y = pos.y,z = pos.z - 2}, + {x = pos.x - 1,y = pos.y,z = pos.z + 2}, + {x = pos.x,y = pos.y,z = pos.z + 2}, + {x = pos.x + 1,y = pos.y,z = pos.z + 2}, + + {x = pos.x + 2,y = pos.y,z = pos.z - 2}, + {x = pos.x + 2,y = pos.y,z = pos.z - 1}, + {x = pos.x + 2,y = pos.y,z = pos.z}, + {x = pos.x + 2,y = pos.y,z = pos.z + 1}, + {x = pos.x + 2,y = pos.y,z = pos.z + 2} + } + + for key,value in pairs(positions) do + if node_exist(leaves,minetest.get_node(value)) then + minetest.set_node(value,{name = "air"}) + end + end + +end +end + +local function fix_everything(pos,size) + if size == 1 then + fix_trunks(pos,1) + elseif size == 2 then + fix_trunks(pos,2) + fix_leaves({x = pos.x,y = pos.y + 4,z = pos.z},1) + elseif size == 3 then + fix_trunks(pos,3) + fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 3,z = pos.z},2) + fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},2) + fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},1) + elseif size == 4 then + fix_trunks(pos,4) + fix_leaves({x = pos.x,y = pos.y,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 1,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 5,z = pos.z},2) + fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},1) + fix_leaves({x = pos.x,y = pos.y + 7,z = pos.z},2) + fix_leaves({x = pos.x,y = pos.y + 10,z = pos.z},1) + end +end + +local function can_grow(pos,size) + + local soil = {"default:dirt","default:dirt_with_grass","default:dirt_with_dry_grass","default:dirt_with_snow"} + local under = {x = pos.x,y = pos.y - 1,z = pos.z} + + if size == 1 then + if minetest.get_node_light({x = pos.x,y = pos.y + 1,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + elseif size == 2 then + if minetest.get_node_light({x = pos.x,y = pos.y + 5,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + elseif size == 3 then + if minetest.get_node_light({x = pos.x,y = pos.y + 8,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + elseif size == 4 then + if minetest.get_node_light({x = pos.x,y = pos.y + 12,z = pos.z}) == 15 and node_exist(soil,minetest.get_node(under)) then + return true + else + return false + end + end +end + +function jungle_growth(pos,size,action) + if action == 1 then + if can_grow(pos,size) then return true else return false end +elseif action == 2 then + if size == 1 then + fix_everything(pos,1) + minetest.place_schematic({x = pos.x - 1,y = pos.y,z = pos.z - 1},minetest.get_modpath("real_trees").."/trees/jungle/schems/small_jungle_tree.mts","0",nil,false) +elseif size == 2 then + fix_everything(pos,2) + minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/jungle/schems/medium_jungle_tree.mts","random",nil,false) +elseif size == 3 then + fix_everything(pos,3) + minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/jungle/schems/large_jungle_tree.mts","random",nil,false) +elseif size == 4 then + fix_everything(pos,4) + minetest.place_schematic({x = pos.x - 2,y = pos.y,z = pos.z - 2},minetest.get_modpath("real_trees").."/trees/jungle/schems/jungle_tree.mts","random",nil,false) + end + end +end diff --git a/trees/jungle/itens.lua b/trees/jungle/itens.lua new file mode 100644 index 0000000..5347f94 --- /dev/null +++ b/trees/jungle/itens.lua @@ -0,0 +1,64 @@ +minetest.register_craft({ + type = "shapeless", + output = "default:junglewood 2", + recipe = {"real_trees:small_jungle_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:junglewood 4", + recipe = {"real_trees:medium_jungle_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:junglewood 6", + recipe = {"real_trees:large_jungle_tree"}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "default:junglewood 8", + recipe = {"default:jungletree"}, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:small_jungle_tree", + burntime = 9.5, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:medium_jungle_tree", + burntime = 19, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "real_trees:large_jungle_tree", + burntime = 28.5, +}) + +minetest.override_item("default:junglesapling",{ + on_timer = function(pos) + jungle_growth(pos,1,2) + end, + + on_construct = function(pos) + if jungle_growth(pos,1,1) then + minetest.get_node_timer(pos):start(growth_time["jungle"] * 1) + end + end, +}) + +minetest.override_item("default:jungletree",{ + tiles = { + "real_trees_alt_jungle_tree_top.png", + "real_trees_alt_jungle_tree_top.png", + "default_jungletree.png", + "default_jungletree.png", + "default_jungletree.png", + "default_jungletree.png", + }, +}) diff --git a/trees/jungle/leaves.lua b/trees/jungle/leaves.lua new file mode 100644 index 0000000..32e027f --- /dev/null +++ b/trees/jungle/leaves.lua @@ -0,0 +1,79 @@ +minetest.register_node("real_trees:small_jungle_leaves", { + description = "Small Jungle Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:jungle_sapling"},rarity = 160}, + {items = {"real_trees:small_leaves"}} + } + }, + + tiles = { "default_jungleleaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}} +}) + +minetest.register_node("real_trees:corner_jungle_leaves", { + description = "Corner Jungle Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:jungle_sapling"},rarity = 160}, + {items = {"real_trees:corner_jungle_leaves"}} + } + }, + + tiles = { "default_jungleleaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{0,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:wide_jungle_leaves", { + description = "Wide Jungle Leaves", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:jungle_sapling"},rarity = 80}, + {items = {"real_trees:wide_jungle_leaves"}} + } + }, + + tiles = { "default_jungleleaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.5,-0.5,0,0.5,0,0.5}}} +}) + +minetest.register_node("real_trees:jungle_leaf_slab", { + description = "Jungle Leaf Slab", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1}, + sounds = default.node_sound_leaves_defaults(), + drop = { + max_items = 1, + items = { + {items = {"default:jungle_sapling"},rarity = 40}, + {items = {"real_trees:jungle_leaf_slab"}} + } + }, + + tiles = { "default_jungleleaves.png" }, + after_place_node = default.after_place_leaves, + node_box = {type = "fixed",fixed = {{-0.5,-0.5,-0.5,0.5,0,0.5}}} +}) diff --git a/trees/jungle/schems/jungle_tree.mts b/trees/jungle/schems/jungle_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..ec889d7c2b80b2121b8bb0d52b7d7f84280579b6 GIT binary patch literal 211 zcmeYb3HD`RVPIw8XJD;I1q{p#%!!#r3?eD1X^EvdC01FbdFeT+IjM4l-n} tG7;|V>)2#HQH%XbdW^cpgK;`|1=hM z3N>Co@UKk4E%c-4_3N`dFD#pHdT?`6`Gy+{*WO&MFFM0tR*l=ETe*2HB$2#GLq&qSVx4tMbg0)cCB@y!4#Z_?*+#PGS;@-rUrb%+g$#ZjgBl@<@7<^NaFQi(t}F!;uvv#$z!-BqcR1 zu{5W|3Su=xTg9B@1O-V0BLhamuMEP>#sZ6(#TLlw1ej^ZOp(;)ekPZ;0tR*l=ETe*2Dzft#GLq&qSVx4tK|Hmywsxjg3P?s_`KBA zl$_LJ1{oyz^30S}R9R^xStM=o#W{&d46;a)Nyz#j(#R$!#^)p!r9%w|Ifg+BNi&*U z#hkl=x49Y=c-#3Q-!JZDSZNn(6n31girvo1 bG{y4Wj}E@WUnU+rP~7v-Xf>ca0|pKT=ETe*2I->I#GLq&qSVx4tAfnD)cCyA)Rdgm_~M+z zBnAZ}$=vwl{Gz;(=UUhA5*t1l5AppZfZ(qX)eTkkb_a& zjxJd-XRfa!SAzkM_w2KLEbZd^UtjM%deElAFxQDwkyS0CuQ|z4lzrNj6FwbNf;t8A l-}m;<`z-FJ&bV!xpZ|)x7r#C!Jacxh-0XMU7gkBH0RR_be5C*Y literal 0 HcmV?d00001 diff --git a/trees/pine/schems/pine_tree.mts b/trees/pine/schems/pine_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..b6f45125230d782a8620493114cc6c4cac576251 GIT binary patch literal 163 zcmeYb3HD`RVPIw8WnisG1`Ny$%!!#r3?eD1X^EvdB~}HQd8zSvsi`SBsl^O}D551r zsi_rnk`ok!3=S!7P4z5fG&<>F8Yz&V)O3_1)zK%hX|~fYokOfkS~+tMH$;eEP?5dT w&vc4$org1bVbP*_6K{xcPfK@GJ>vL?Lr*VuiAB51*B84!zF=q2Jh<={0Kb7fF#rGn literal 0 HcmV?d00001 diff --git a/trees/pine/schems/small_pine_tree.mts b/trees/pine/schems/small_pine_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..5b7d95594e90d68223233a211c1599c0c4b92c0a GIT binary patch literal 303 zcmeYb3HD`RVPFQ~dLUrnU|>$nEMib7N=?j(FDXh*Ew;*yPtGsOOD&2o$jnQP&r3~B z$w@6{kV8>Xo|%%0TOON!86^Ffx{+lQb8;ZYgPg=5g`^i*V+m)teG&=*@Y#IZL>wQ#svj| S*`1yNJ-jCv7(V?K+5!O1j%tPg literal 0 HcmV?d00001 diff --git a/trees/pine/trunks.lua b/trees/pine/trunks.lua new file mode 100644 index 0000000..5acd345 --- /dev/null +++ b/trees/pine/trunks.lua @@ -0,0 +1,128 @@ +minetest.register_node("real_trees:small_pine_tree", { + description = "Small Pine Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:small_pine_tree", + tiles = { + "real_trees_small_pine_tree_top.png", + "real_trees_small_pine_tree_top.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}} +}) + +minetest.register_node("real_trees:medium_pine_tree", { + description = "Medium Pine Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:medium_pine_tree", + tiles = { + "real_trees_medium_pine_tree_top.png", + "real_trees_medium_pine_tree_top.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}} +}) + +minetest.register_node("real_trees:large_pine_tree", { + description = "Large Pine Tree", + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:large_pine_tree", + tiles = { + "real_trees_large_pine_tree_top.png", + "real_trees_large_pine_tree_top.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + }, + + on_place = minetest.rotate_node, + node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}} +}) + +minetest.register_node("real_trees:a_small_pine_tree", { + description = "A Small Pine Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:small_pine_tree", + tiles = { + "real_trees_small_pine_tree_top.png", + "real_trees_small_pine_tree_top.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + }, + + node_box = {type = "fixed",fixed = {{-0.125,-0.5,0.125,0.125,0.5,-0.125}}}, + on_timer = function(pos) + pine_growth(pos,2,2) + end +}) + +minetest.register_node("real_trees:a_medium_pine_tree", { + description = "A Medium Pine Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:medium_pine_tree", + tiles = { + "real_trees_medium_pine_tree_top.png", + "real_trees_medium_pine_tree_top.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + }, + + node_box = {type = "fixed",fixed = {{-0.25,-0.5,0.25,0.25,0.5,-0.25}}}, + on_timer = function(pos) + pine_growth(pos,3,2) + end +}) + +minetest.register_node("real_trees:a_large_pine_tree", { + description = "A Large Pine Tree", + drawtype = "nodebox", + paramtype = "light", + groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3, not_in_creative_inventory = 1}, + sounds = default.node_sound_wood_defaults(), + drop = "real_trees:large_pine_tree", + tiles = { + "real_trees_large_pine_tree_top.png", + "real_trees_large_pine_tree_top.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + "default_pine_tree.png", + }, + + node_box = {type = "fixed",fixed = {{-0.375,-0.5,0.375,0.375,0.5,-0.375}}}, + on_timer = function(pos) + pine_growth(pos,4,2) + end, +})