From 966c5fc4b0c76408bc5c83e1b03bd175732485f8 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Mon, 11 Feb 2013 00:09:53 -0500 Subject: [PATCH] added leafdecay, fixed broken birch sideways trunk recipe, made all cones + apple fall when they have nothing to hang onto. --- crafts.lua | 22 +++++++++++----------- init.lua | 21 ++++++++++++++++++++- node_defs.lua | 46 ++++++++++++++++++++++++++-------------------- 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/crafts.lua b/crafts.lua index d32f86e..58f41fc 100644 --- a/crafts.lua +++ b/crafts.lua @@ -1,33 +1,33 @@ -for i in ipairs(simple_trees) do +for i in ipairs(moretrees.simple_trees) do minetest.register_craft({ - output = "moretrees:"..simple_trees[i].."_trunk_sideways 2", + output = "moretrees:"..moretrees.simple_trees[i].."_trunk_sideways 2", recipe = { - {"moretrees:"..simple_trees[i].."_trunk", "moretrees:"..simple_trees[i].."_trunk"} + {"moretrees:"..moretrees.simple_trees[i].."_trunk", "moretrees:"..moretrees.simple_trees[i].."_trunk"} } }) minetest.register_craft({ - output = "moretrees:"..simple_trees[i].."_trunk 2", + output = "moretrees:"..moretrees.simple_trees[i].."_trunk 2", recipe = { - {"moretrees:"..simple_trees[i].."_trunk_sideways"}, - {"moretrees:"..simple_trees[i].."_trunk_sideways"} + {"moretrees:"..moretrees.simple_trees[i].."_trunk_sideways"}, + {"moretrees:"..moretrees.simple_trees[i].."_trunk_sideways"} } }) minetest.register_craft({ type = "shapeless", - output = "moretrees:"..simple_trees[i].."_planks 4", + output = "moretrees:"..moretrees.simple_trees[i].."_planks 4", recipe = { - "moretrees:"..simple_trees[i].."_trunk" + "moretrees:"..moretrees.simple_trees[i].."_trunk" } }) minetest.register_craft({ type = "shapeless", - output = "moretrees:"..simple_trees[i].."_planks 4", + output = "moretrees:"..moretrees.simple_trees[i].."_planks 4", recipe = { - "moretrees:"..simple_trees[i].."_trunk_sideways" + "moretrees:"..moretrees.simple_trees[i].."_trunk_sideways" } }) end @@ -130,7 +130,7 @@ minetest.register_craft({ minetest.register_craft({ output = "moretrees:birch_trunk_sideways 2", recipe = { - {"moretrees:birch_trunk", "moretrees:spruce_trunk"}, + {"moretrees:birch_trunk", "moretrees:birch_trunk"}, } }) diff --git a/init.lua b/init.lua index fbd2c6c..2dfd618 100644 --- a/init.lua +++ b/init.lua @@ -64,7 +64,7 @@ plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model) local sapling_interval = 500 local sapling_chance = 20 -for i in ipairs(simple_trees) do +for i in ipairs(moretrees.simple_trees) do local tree_name = trees[i][1] local tree_model = tree_name.."_model" local tree_biome = tree_name.."_biome" @@ -233,4 +233,23 @@ if CONIFERS_REMOVE_TREES == true then }) end +-- leaf decay + + +local leafdecay_delay = 2 +local leafdecay_chance = 150 +local leafdecay_radius = 5 + +minetest.register_abm({ + nodenames = moretrees.leaves_list, + interval = leafdecay_delay, + chance = leafdecay_chance, + action = function(pos, node, active_object_count, active_object_count_wider) + if not minetest.env:find_node_near(pos, leafdecay_radius, moretrees.trunks_list) then + minetest.env:remove_node(pos) + minetest.env:dig_node(pos) + end + end +}) + print("[Moretrees] Loaded (2013-01-18)") diff --git a/node_defs.lua b/node_defs.lua index 84eac02..c832b6d 100644 --- a/node_defs.lua +++ b/node_defs.lua @@ -10,30 +10,33 @@ table.insert(moretrees.avoidnodes, "moretrees:fir_leaves") table.insert(moretrees.avoidnodes, "moretrees:fir_leaves_bright") trees = { - {"beech", "Beech Tree", 4 }, - {"apple_tree", "Apple Tree", 10 }, - {"oak", "Oak Tree", 10, "acorn", "Acorn", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, - {"sequoia", "Giant Sequoia", 7 }, - {"birch", "Birch Tree", 10 }, - {"palm", "Palm Tree", 15, "coconut", "Coconut", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 1.0 }, - {"spruce", "Spruce Tree", 10, "spruce_cone", "Spruce Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, - {"pine", "Pine Tree", 10, "pine_cone", "Pine Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, - {"willow", "Willow Tree", 15 }, - {"rubber_tree", "Rubber Tree", 7 }, + {"beech", "Beech Tree"}, + {"apple_tree", "Apple Tree"}, + {"oak", "Oak Tree", "acorn", "Acorn", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, + {"sequoia", "Giant Sequoia"}, + {"birch", "Birch Tree"}, + {"palm", "Palm Tree", "coconut", "Coconut", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 1.0 }, + {"spruce", "Spruce Tree", "spruce_cone", "Spruce Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, + {"pine", "Pine Tree", "pine_cone", "Pine Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, + {"willow", "Willow Tree"}, + {"rubber_tree", "Rubber Tree"}, {"jungletree", "Jungle Tree"}, - {"fir", "Douglas Fir", 15, "fir_cone", "Fir Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, + {"fir", "Douglas Fir", "fir_cone", "Fir Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, } -simple_trees = { "beech", "apple_tree", "oak", "sequoia", "palm", "pine", "willow", "rubber_tree"} +moretrees.simple_trees = { "beech", "apple_tree", "oak", "sequoia", "palm", "pine", "willow", "rubber_tree"} + +moretrees.leaves_list = {} +moretrees.trunks_list = {} for i in ipairs(trees) do local treename = trees[i][1] local treedesc = trees[i][2] - local leafdecayradius = trees[i][3] -- future use, not yet implemented. - local fruit = trees[i][4] - local fruitdesc = trees[i][5] - local selbox = trees[i][6] - local vscale = trees[i][7] + local fruit = trees[i][3] + local fruitdesc = trees[i][4] + local selbox = trees[i][5] + local vscale = trees[i][6] + minetest.register_node("moretrees:"..treename.."_trunk", { description = treedesc.." Trunk", @@ -101,7 +104,7 @@ for i in ipairs(trees) do type = "fixed", fixed = selbox }, - groups = {fleshy=3,dig_immediate=3,flammable=2}, + groups = {fleshy=3,dig_immediate=3,flammable=2, attached_node=1}, sounds = default.node_sound_defaults(), }) end @@ -116,7 +119,7 @@ for i in ipairs(trees) do drawtype = "allfaces_optional", tiles = { "moretrees_"..treename.."_leaves.png" }, paramtype = "light", - groups = {tree=1, snappy=3, flammable=2 }, + groups = {tree=1, snappy=3, flammable=2}, sounds = default.node_sound_leaves_defaults(), drop = { @@ -131,6 +134,8 @@ for i in ipairs(trees) do table.insert(moretrees.avoidnodes, "moretrees:"..treename.."_trunk") table.insert(moretrees.avoidnodes, "moretrees:"..treename.."_leaves") + table.insert(moretrees.leaves_list, "moretrees:"..treename.."_leaves") + table.insert(moretrees.trunks_list, "moretrees:"..treename.."_trunk") end -- Extra leaves for jungle trees: @@ -154,6 +159,7 @@ for color = 1, 3 do }, sounds = default.node_sound_leaves_defaults(), }) + table.insert(moretrees.leaves_list, "moretrees:jungletree_leaves_"..jungleleaves[color]) end -- Extra needles for firs @@ -174,7 +180,7 @@ minetest.register_node("moretrees:fir_leaves_bright", { }, sounds = default.node_sound_leaves_defaults() }) - +table.insert(moretrees.leaves_list, "moretrees:fir_leaves_bright") -- Backward compatbility with old mods/nodes: -- 2.30.2