From: Vanessa Ezekowitz Date: Sun, 20 Jan 2013 05:01:15 +0000 (-0500) Subject: Enabled several new types of trees, all spawned at mapgen time! X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=2c3345aa046f779c41fa7428e1efa0a0176b4e0f;p=zefram%2Fminetest%2Fmoretrees.git Enabled several new types of trees, all spawned at mapgen time! This code will slow the map generator down a little due to bugs therein, and is generally still in the experimental stages, but it works and is actually quite fast! --- diff --git a/biome_defs.lua b/biome_defs.lua index c03f673..3b48117 100644 --- a/biome_defs.lua +++ b/biome_defs.lua @@ -2,7 +2,7 @@ -- Example biome definition: -mytree_biome = { +moretrees.mytree_biome = { surface = "default:dirt_with_grass", -- must grow on these nodes only avoid_nodes = {"default:tree"}, -- avoid spawning near these avoid_radius = 12, -- Keep this much room around the above avoid items @@ -20,27 +20,11 @@ mytree_biome = { } ]]-- -moretrees.jungletree_biome = { - surface = "default:dirt_with_grass", - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 12, - seed_diff = 329, - min_elevation = -5, - max_elevation = 10, - near_nodes = {"default:water_source"}, - near_nodes_size = 15, - near_nodes_count = 10, --- temp_min = 0.05, -} - -moretrees.conifer_biome = { +moretrees.beech_biome = { surface = "default:dirt_with_grass", avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, - seed_diff = 359, - min_elevation = 25, - temp_min = 0.9, - temp_max = 0.3, + seed_diff = 2, } moretrees.palm_biome = { @@ -57,7 +41,7 @@ moretrees.palm_biome = { temp_max = -0.15, } -moretrees.apple_biome = { +moretrees.apple_tree_biome = { surface = "default:dirt_with_grass", avoid_nodes = moretrees.avoidnodes, avoid_radius = 15, @@ -133,7 +117,7 @@ moretrees.willow_biome = { near_nodes_count = 5, } -moretrees.rubber_biome = { +moretrees.rubber_tree_biome = { surface = "default:dirt_with_grass", avoid_nodes = moretrees.avoidnodes, avoid_radius = 20, @@ -146,3 +130,26 @@ moretrees.rubber_biome = { temp_min = -0.15, } + +moretrees.jungletree_biome = { + surface = "default:dirt_with_grass", + avoid_nodes = moretrees.avoidnodes, + avoid_radius = 12, + seed_diff = 329, + min_elevation = -5, + max_elevation = 10, + near_nodes = {"default:water_source"}, + near_nodes_size = 15, + near_nodes_count = 10, +-- temp_min = 0.05, +} + +moretrees.conifer_biome = { + surface = "default:dirt_with_grass", + avoid_nodes = moretrees.avoidnodes, + avoid_radius = 10, + seed_diff = 359, + min_elevation = 25, + temp_min = 0.9, + temp_max = 0.3, +} diff --git a/init.lua b/init.lua index ff0bcf4..9b2de3c 100644 --- a/init.lua +++ b/init.lua @@ -34,20 +34,50 @@ dofile(minetest.get_modpath("moretrees").."/node_defs.lua") dofile(minetest.get_modpath("moretrees").."/tree_models.lua") dofile(minetest.get_modpath("moretrees").."/biome_defs.lua") +plantslib:register_generate_plant(moretrees.apple_tree_biome, moretrees.apple_tree_model) +plantslib:register_generate_plant(moretrees.oak_biome, moretrees.oak_model) +plantslib:register_generate_plant(moretrees.sequoia_biome, moretrees.sequoia_model) +plantslib:register_generate_plant(moretrees.palm_biome, moretrees.palm_model) +plantslib:register_generate_plant(moretrees.pine_biome, moretrees.pine_model) +plantslib:register_generate_plant(moretrees.rubber_tree_biome, moretrees.rubber_tree_model) +plantslib:register_generate_plant(moretrees.willow_biome, moretrees.willow_model) + +plantslib:register_generate_plant(moretrees.birch_biome, "moretrees:grow_birch") +plantslib:register_generate_plant(moretrees.spruce_biome, "moretrees:grow_spruce") plantslib:register_generate_plant(moretrees.jungletree_biome, "moretrees:grow_jungletree") plantslib:register_generate_plant(moretrees.conifer_biome, "moretrees:grow_conifer") ---plantslib:register_generate_plant(moretrees.palm_biome, moretrees.palm_model) +-- These three lines replace default trees with beech +-- Enable them if you want but be warned - due to serious bugs in the speed +-- of the engine's map generator/loader, doing so will slow it WAY down. --------------------------- --- Other stuff --- --- for backward compatibility with previous mods/code, jungle trees and --- firs ("conifers") L-Systems definitions are established separately. --- --------------------------- +--[[ +minetest.register_alias("mapgen_tree", "air") +minetest.register_alias("mapgen_leaves", "air") +plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model) +]]-- + +-- Code to spawn a birch tree + +function moretrees:grow_birch(pos) + if math.random(1,2) == 1 then + minetest.env:spawn_tree(pos, moretrees.birch_model1) + else + minetest.env:spawn_tree(pos, moretrees.birch_model2) + end +end + +-- Code to spawn a spruce tree + +function moretrees:grow_spruce(pos) + if math.random(1,2) == 1 then + minetest.env:spawn_tree(pos, moretrees.spruce_model1) + else + minetest.env:spawn_tree(pos, moretrees.spruce_model2) + end +end --- Code that spawns jungle trees and firs ("conifers") +-- Code that spawns jungle trees and firs ("conifer") moretrees.jt_axiom1 = "FFFA" moretrees.jt_rules_a1 = "FFF[&&-FBf[&&&Ff]^^^Ff][&&+FBFf[&&&FFf]^^^Ff][&&---FBFf[&&&Ff]^^^Ff][&&+++FBFf[&&&Ff]^^^Ff]F/A" diff --git a/tree_models.lua b/tree_models.lua index dd78024..e836858 100644 --- a/tree_models.lua +++ b/tree_models.lua @@ -1,185 +1,185 @@ -beech_model={ -axiom="FFFFFBFB", -rules_a="[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fd]]////[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fd]]////[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fdd]]", -rules_b="[&&&F[++^Fd][--&d]//d[+^d][--&d]]////[&&&F[++^Fd][--&d]//d[+^d][--&d]]////[&&&F[++^Fd][--&Fd]//d[+^d][--&d]]", -rules_c="/", -rules_d="F", -trunk="moretrees:beech_trunk", -leaves="moretrees:beech_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="single"; -thin_branches=true; +moretrees.beech_model={ + axiom="FFFFFBFB", + rules_a="[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fd]]////[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fd]]////[&&&GGF[++^Fd][--&Fd]//Fd[+^Fd][--&Fdd]]", + rules_b="[&&&F[++^Fd][--&d]//d[+^d][--&d]]////[&&&F[++^Fd][--&d]//d[+^d][--&d]]////[&&&F[++^Fd][--&Fd]//d[+^d][--&d]]", + rules_c="/", + rules_d="F", + trunk="moretrees:beech_trunk", + leaves="moretrees:beech_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="single"; + thin_branches=true; } -apple_tree_model={ -axiom="FFFFFAFFBF", -rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]", -rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]", -trunk="moretrees:apple_tree_trunk", -leaves="moretrees:apple_tree_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="single", -thin_branches=true; -fruit="default:apple", -fruit_chance=15, +moretrees.apple_tree_model={ + axiom="FFFFFAFFBF", + rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]", + rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]", + trunk="moretrees:apple_tree_trunk", + leaves="moretrees:apple_tree_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="single", + thin_branches=true; + fruit="default:apple", + fruit_chance=15, } -oak_model={ -axiom="FFFFFFA", -rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]", -rules_b="[&FFFA]////[&FFFA]////[&FFFA]", -trunk="moretrees:oak_trunk", -leaves="moretrees:oak_leaves", -angle=30, -iterations=5, -random_level=2, -trunk_type="crossed"; -thin_branches=false; -fruit="moretrees:acorn", -fruit_chance=3, +moretrees.oak_model={ + axiom="FFFFFFA", + rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]", + rules_b="[&FFFA]////[&FFFA]////[&FFFA]", + trunk="moretrees:oak_trunk", + leaves="moretrees:oak_leaves", + angle=30, + iterations=5, + random_level=2, + trunk_type="crossed"; + thin_branches=false; + fruit="moretrees:acorn", + fruit_chance=3, } -sequoia_model={ -axiom="FFFFFFFFFFddccA///cccFddcFA///ddFcFA/cFFddFcdBddd/A/ccdcddd/ccAddddcFBcccAccFdFcFBcccc/BFdFFcFFdcccc/B", -rules_a="[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]////[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]////[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]", -rules_b="[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]////[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]////[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]", -rules_c="/", -rules_d="F", -trunk="moretrees:sequoia_trunk", -leaves="moretrees:sequoia_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="crossed", -thin_branches=true +moretrees.sequoia_model={ + axiom="FFFFFFFFFFddccA///cccFddcFA///ddFcFA/cFFddFcdBddd/A/ccdcddd/ccAddddcFBcccAccFdFcFBcccc/BFdFFcFFdcccc/B", + rules_a="[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]////[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]////[&&&GGF[++^FFdd][--&Fddd]//Fdd[+^Fd][--&Fdd]]", + rules_b="[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]////[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]////[&&&GGF[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]", + rules_c="/", + rules_d="F", + trunk="moretrees:sequoia_trunk", + leaves="moretrees:sequoia_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="crossed", + thin_branches=true } -birch_model1={ -axiom="FFFFFdddccA/FFFFFFcA/FFFFFFcB", -rules_a="[&&&dddd^^ddddddd][&&&---dddd^^ddddddd][&&&+++dddd^^ddddddd][&&&++++++dddd^^ddddddd]", -rules_b="[&&&ddd^^ddddd][&&&---ddd^^ddddd][&&&+++ddd^^ddddd][&&&++++++ddd^^ddddd]", -rules_c="/", -rules_d="F", -trunk="moretrees:birch_trunk", -leaves="moretrees:birch_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="single", -thin_branches=true +moretrees.birch_model1={ + axiom="FFFFFdddccA/FFFFFFcA/FFFFFFcB", + rules_a="[&&&dddd^^ddddddd][&&&---dddd^^ddddddd][&&&+++dddd^^ddddddd][&&&++++++dddd^^ddddddd]", + rules_b="[&&&ddd^^ddddd][&&&---ddd^^ddddd][&&&+++ddd^^ddddd][&&&++++++ddd^^ddddd]", + rules_c="/", + rules_d="F", + trunk="moretrees:birch_trunk", + leaves="moretrees:birch_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="single", + thin_branches=true } -birch_model2={ -axiom="FFFdddccA/FFFFFccA/FFFFFccB", -rules_a="[&&&dFFF^^FFFdd][&&&---dFFF^^FFFdd][&&&+++dFFF^^FFFdd][&&&++++++dFFF^^FFFdd]", -rules_b="[&&&dFF^^FFFd][&&&---dFFF^^FFFd][&&&+++dFF^^FFFd][&&&++++++dFF^^FFFd]", -rules_c="/", -rules_d="F", -trunk="moretrees:birch_trunk", -leaves="moretrees:birch_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="single", -thin_branches=true +moretrees.birch_model2={ + axiom="FFFdddccA/FFFFFccA/FFFFFccB", + rules_a="[&&&dFFF^^FFFdd][&&&---dFFF^^FFFdd][&&&+++dFFF^^FFFdd][&&&++++++dFFF^^FFFdd]", + rules_b="[&&&dFF^^FFFd][&&&---dFFF^^FFFd][&&&+++dFF^^FFFd][&&&++++++dFF^^FFFd]", + rules_c="/", + rules_d="F", + trunk="moretrees:birch_trunk", + leaves="moretrees:birch_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="single", + thin_branches=true } -palm_model={ -axiom="FFccc&FFFFFdddFA//A//A//A//A//A", -rules_a="[&fb&bbb[++f--&ffff&ff][--f++&ffff&ff]&ffff&bbbb&b]", -rules_b="f", -rules_c="/", -rules_d="F", -trunk="moretrees:palm_trunk", -leaves="moretrees:palm_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="single", -thin_branches=true, -fruit="moretrees:coconut", -fruit_chance=0 +moretrees.palm_model={ + axiom="FFccc&FFFFFdddFA//A//A//A//A//A", + rules_a="[&fb&bbb[++f--&ffff&ff][--f++&ffff&ff]&ffff&bbbb&b]", + rules_b="f", + rules_c="/", + rules_d="F", + trunk="moretrees:palm_trunk", + leaves="moretrees:palm_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="single", + thin_branches=true, + fruit="moretrees:coconut", + fruit_chance=0 } -spruce_model1={ -axiom="FFFFFAFFFFFFBFFFFFFCFFFFFFDFFFFFF[&&&F^^FF][&&&++F^^FF][&&&++++F^^FF][&&&++++++F^^FF][&&&--F^^FF][&&&----F^^FF][FFFFf]", -rules_a="[&&&FFFFFF^^FFF][&&&++FFFFFF^^FFF][&&&++++FFFFFF^^FFF][&&&++++++FFFFFF^^FFF][&&&--FFFFFF^^FFF][&&&----FFFFFF^^FFF]", -rules_b="[&&&FFFFF^^FFF][&&&++FFFFF^^FFF][&&&++++FFFFF^^FFF][&&&++++++FFFFF^^FFF][&&&--FFFFF^^FFF][&&&----FFFFF^^FFF]", -rules_c="[&&&FFFF^^FFF][&&&++FFFF^^FFF][&&&++++FFFF^^FFF][&&&++++++FFFF^^FFF][&&&--FFFF^^FFF][&&&----FFFF^^FFF]", -rules_d="[&&&FFF^^FFF][&&&++FFF^^FFF][&&&++++FFF^^FFF][&&&++++++FFF^^FFF][&&&--FFF^^FFF][&&&----FFF^^FFF]", -trunk="moretrees:spruce_trunk", -leaves="moretrees:spruce_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="crossed", -thin_branches=true, -fruit="moretrees:cone", -fruit_chance=8 +moretrees.spruce_model1={ + axiom="FFFFFAFFFFFFBFFFFFFCFFFFFFDFFFFFF[&&&F^^FF][&&&++F^^FF][&&&++++F^^FF][&&&++++++F^^FF][&&&--F^^FF][&&&----F^^FF][FFFFf]", + rules_a="[&&&FFFFFF^^FFF][&&&++FFFFFF^^FFF][&&&++++FFFFFF^^FFF][&&&++++++FFFFFF^^FFF][&&&--FFFFFF^^FFF][&&&----FFFFFF^^FFF]", + rules_b="[&&&FFFFF^^FFF][&&&++FFFFF^^FFF][&&&++++FFFFF^^FFF][&&&++++++FFFFF^^FFF][&&&--FFFFF^^FFF][&&&----FFFFF^^FFF]", + rules_c="[&&&FFFF^^FFF][&&&++FFFF^^FFF][&&&++++FFFF^^FFF][&&&++++++FFFF^^FFF][&&&--FFFF^^FFF][&&&----FFFF^^FFF]", + rules_d="[&&&FFF^^FFF][&&&++FFF^^FFF][&&&++++FFF^^FFF][&&&++++++FFF^^FFF][&&&--FFF^^FFF][&&&----FFF^^FFF]", + trunk="moretrees:spruce_trunk", + leaves="moretrees:spruce_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="crossed", + thin_branches=true, + fruit="moretrees:cone", + fruit_chance=8 } -spruce_model2={ -axiom="FFFFFFBFFFFFFCFFFFFFDFFFFFF[&&&F^^FF][&&&++F^^FF][&&&++++F^^FF][&&&++++++F^^FF][&&&--F^^FF][&&&----F^^FF][FFFFf]", -rules_b="[&&&FFFFF^^FFF][&&&++FFFFF^^FFF][&&&++++FFFFF^^FFF][&&&++++++FFFFF^^FFF][&&&--FFFFF^^FFF][&&&----FFFFF^^FFF]", -rules_c="[&&&FFFF^^FFF][&&&++FFFF^^FFF][&&&++++FFFF^^FFF][&&&++++++FFFF^^FFF][&&&--FFFF^^FFF][&&&----FFFF^^FFF]", -rules_d="[&&&FFF^^FFF][&&&++FFF^^FFF][&&&++++FFF^^FFF][&&&++++++FFF^^FFF][&&&--FFF^^FFF][&&&----FFF^^FFF]", -trunk="moretrees:spruce_trunk", -leaves="moretrees:spruce_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="crossed", -thin_branches=true, -fruit="moretrees:cone", -fruit_chance=8 +moretrees.spruce_model2={ + axiom="FFFFFFBFFFFFFCFFFFFFDFFFFFF[&&&F^^FF][&&&++F^^FF][&&&++++F^^FF][&&&++++++F^^FF][&&&--F^^FF][&&&----F^^FF][FFFFf]", + rules_b="[&&&FFFFF^^FFF][&&&++FFFFF^^FFF][&&&++++FFFFF^^FFF][&&&++++++FFFFF^^FFF][&&&--FFFFF^^FFF][&&&----FFFFF^^FFF]", + rules_c="[&&&FFFF^^FFF][&&&++FFFF^^FFF][&&&++++FFFF^^FFF][&&&++++++FFFF^^FFF][&&&--FFFF^^FFF][&&&----FFFF^^FFF]", + rules_d="[&&&FFF^^FFF][&&&++FFF^^FFF][&&&++++FFF^^FFF][&&&++++++FFF^^FFF][&&&--FFF^^FFF][&&&----FFF^^FFF]", + trunk="moretrees:spruce_trunk", + leaves="moretrees:spruce_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="crossed", + thin_branches=true, + fruit="moretrees:cone", + fruit_chance=8 } -pine_model={ -axiom="FFFFFcccdddB///cFdFB////cFdFB///cFdFB///cFdFA///cFdFA///cFdFB[FF]f", -rules_a="[&&&TTTT[++^TFdd][--&TFd]//Tdd[+^Fd][--&Fdd]]", -rules_b="[&&&TTT[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]", -rules_c="/", -rules_d="F", -trunk="moretrees:pine_trunk", -leaves="moretrees:pine_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="single", -thin_branches=true, -fruit="moretrees:pine_cone", -fruit_chance=8 +moretrees.pine_model={ + axiom="FFFFFcccdddB///cFdFB////cFdFB///cFdFB///cFdFA///cFdFA///cFdFB[FF]f", + rules_a="[&&&TTTT[++^TFdd][--&TFd]//Tdd[+^Fd][--&Fdd]]", + rules_b="[&&&TTT[++^Fdd][--&Fdd]//dd[+^d][--&Fd]]", + rules_c="/", + rules_d="F", + trunk="moretrees:pine_trunk", + leaves="moretrees:pine_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="single", + thin_branches=true, + fruit="moretrees:pine_cone", + fruit_chance=8 } -willow_model={ -axiom="FFFFFFFFccA", -rules_a="[&FF&FFFF&&F&FFFFFFFdddd][**&FF&FFFF&&F&FFFFFFFdddd][//&FF&FFFF&&F&FFFFFFFdddd][////&FF&FFFF&&F&FFFFFFFdddd][//////&FF&FFFF&&F&FFFFFFFdddd][////////&FF&FFFF&&F&FFFFFFFdddd]", -rules_c="/", -rules_d="F", -trunk="moretrees:willow_trunk", -leaves="moretrees:willow_leaves", -angle=30, -iterations=2, -random_level=0, -trunk_type="crossed", -thin_branches=true +moretrees.willow_model={ + axiom="FFFFFFFFccA", + rules_a="[&FF&FFFF&&F&FFFFFFFdddd][**&FF&FFFF&&F&FFFFFFFdddd][//&FF&FFFF&&F&FFFFFFFdddd][////&FF&FFFF&&F&FFFFFFFdddd][//////&FF&FFFF&&F&FFFFFFFdddd][////////&FF&FFFF&&F&FFFFFFFdddd]", + rules_c="/", + rules_d="F", + trunk="moretrees:willow_trunk", + leaves="moretrees:willow_leaves", + angle=30, + iterations=2, + random_level=0, + trunk_type="crossed", + thin_branches=true } -rubber_tree={ -axiom="FFFFA", -rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]", -rules_b="[&FFA]////[&FFA]////[&FFA]", -trunk="moretrees:rubber_tree_trunk", -leaves="moretrees:rubber_tree_leaves", -angle=35, -iterations=3, -random_level=1, -trunk_type="double", -thin_branches=true +moretrees.rubber_tree_model={ + axiom="FFFFA", + rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]", + rules_b="[&FFA]////[&FFA]////[&FFA]", + trunk="moretrees:rubber_tree_trunk", + leaves="moretrees:rubber_tree_leaves", + angle=35, + iterations=3, + random_level=1, + trunk_type="double", + thin_branches=true } moretrees.jungletree_model={ @@ -208,5 +208,6 @@ moretrees.conifer_model={ angle=45, iterations=7, random_level=5, - thin_trunks=true + trunk_type="single", + thin_branches=true }