2013-01-20 07:39:00 +01:00
|
|
|
-- More trees! 2013-01-20
|
2013-01-10 03:35:50 +01:00
|
|
|
--
|
|
|
|
-- This mod adds more types of trees to the game
|
|
|
|
--
|
2013-01-20 00:36:13 +01:00
|
|
|
-- Some of the node definitions and textures came from cisoun's conifers mod
|
|
|
|
-- and bas080's jungle trees mod.
|
2013-01-10 03:35:50 +01:00
|
|
|
--
|
|
|
|
-- Brought together into one mod and made L-systems compatible by Vanessa
|
2013-01-20 07:39:00 +01:00
|
|
|
-- Ezekowitz.
|
2013-01-10 03:35:50 +01:00
|
|
|
--
|
2013-01-20 00:36:13 +01:00
|
|
|
-- Conifers and Jungle tree axioms/rules by Vanessa Ezekowitz, with the
|
|
|
|
-- latter having been tweaked by RealBadAngel, most others written by
|
|
|
|
-- RealBadAngel.
|
2013-01-10 03:35:50 +01:00
|
|
|
--
|
2013-01-10 04:30:55 +01:00
|
|
|
-- License: WTFPL for all parts (code and textures)
|
|
|
|
--
|
2013-01-10 03:35:50 +01:00
|
|
|
|
2013-01-14 02:37:05 +01:00
|
|
|
-- snow biomes mod uses this code to make biomes:
|
|
|
|
--
|
2013-01-19 03:35:39 +01:00
|
|
|
-- local perlin1 = env:get_perlin(112,3, 0.5, 150)
|
|
|
|
-- local test = perlin1:get2d({x=pos.x, y=pos.z})
|
|
|
|
-- if smooth and (test > 0.73 or (test > 0.43 and math.random(0,29) > (0.73 - test) * 100 )) then
|
|
|
|
-- in_biome = true
|
|
|
|
-- elseif not smooth and test > 0.53 then
|
|
|
|
-- in_biome = true
|
|
|
|
-- end
|
|
|
|
--
|
2013-01-20 00:36:13 +01:00
|
|
|
-- We'll just save this for possible later use ;-)
|
2013-01-14 02:37:05 +01:00
|
|
|
--
|
2013-01-19 03:35:39 +01:00
|
|
|
moretrees = {}
|
2013-01-10 03:35:50 +01:00
|
|
|
|
2013-01-20 00:36:13 +01:00
|
|
|
dofile(minetest.get_modpath("moretrees").."/crafts.lua")
|
|
|
|
dofile(minetest.get_modpath("moretrees").."/node_defs.lua")
|
|
|
|
dofile(minetest.get_modpath("moretrees").."/tree_models.lua")
|
|
|
|
dofile(minetest.get_modpath("moretrees").."/biome_defs.lua")
|
2013-01-10 03:35:50 +01:00
|
|
|
|
2013-01-20 19:38:23 +01:00
|
|
|
-- tree spawning setup
|
|
|
|
|
2013-01-20 06:01:15 +01:00
|
|
|
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")
|
2013-01-20 00:36:13 +01:00
|
|
|
plantslib:register_generate_plant(moretrees.jungletree_biome, "moretrees:grow_jungletree")
|
|
|
|
plantslib:register_generate_plant(moretrees.conifer_biome, "moretrees:grow_conifer")
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 06:01:15 +01:00
|
|
|
-- 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.
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 06:01:15 +01:00
|
|
|
--[[
|
|
|
|
minetest.register_alias("mapgen_tree", "air")
|
|
|
|
minetest.register_alias("mapgen_leaves", "air")
|
|
|
|
plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model)
|
|
|
|
]]--
|
|
|
|
|
2013-01-20 19:38:23 +01:00
|
|
|
-- sapling growth setup
|
|
|
|
|
2013-01-20 19:51:34 +01:00
|
|
|
local sapling_interval = 500
|
|
|
|
local sapling_chance = 10
|
|
|
|
|
2013-01-20 19:38:23 +01:00
|
|
|
for i in ipairs(simple_trees) do
|
|
|
|
local tree_name = trees[i][1]
|
|
|
|
local tree_model = tree_name.."_model"
|
2013-01-20 19:51:34 +01:00
|
|
|
dbg(dump(moretrees[tree_model]))
|
2013-01-20 20:15:33 +01:00
|
|
|
|
2013-01-20 20:17:04 +01:00
|
|
|
if tree_model == "palm_model" then
|
2013-01-20 20:15:33 +01:00
|
|
|
grow_nodes = {"default:sand"}
|
|
|
|
else
|
|
|
|
grow_nodes = {"default:dirt_with_grass"}
|
|
|
|
end
|
2013-01-20 19:38:23 +01:00
|
|
|
|
|
|
|
plantslib:grow_plants(
|
|
|
|
sapling_interval,
|
|
|
|
sapling_chance,
|
|
|
|
"moretrees:"..tree_name.."_sapling",
|
|
|
|
nil,
|
|
|
|
nil,
|
2013-01-20 20:15:33 +01:00
|
|
|
grow_nodes,
|
2013-01-20 19:38:23 +01:00
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
moretrees[tree_model],
|
|
|
|
nil
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
plantslib:grow_plants(sapling_interval,sapling_chance,"moretrees:birch_sapling",nil,nil,nil,nil,nil,nil,nil,nil,"moretrees:grow_birch",nil)
|
|
|
|
plantslib:grow_plants(sapling_interval,sapling_chance,"moretrees:spruce_sapling",nil,nil,nil,nil,nil,nil,nil,nil,"moretrees:grow_spruce",nil)
|
|
|
|
plantslib:grow_plants(sapling_interval,sapling_chance,"conifers:sapling",nil,nil,nil,nil,nil,nil,nil,nil,"moretrees:grow_conifer",nil)
|
|
|
|
plantslib:grow_plants(sapling_interval,sapling_chance,"jungletree:sapling",nil,nil,nil,nil,nil,nil,nil,nil,"moretrees:grow_jungletree",nil)
|
|
|
|
|
2013-01-20 06:01:15 +01:00
|
|
|
-- Code to spawn a birch tree
|
|
|
|
|
|
|
|
function moretrees:grow_birch(pos)
|
2013-01-20 20:04:10 +01:00
|
|
|
minetest.env:remove_node(pos)
|
2013-01-20 06:01:15 +01:00
|
|
|
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)
|
2013-01-20 20:04:10 +01:00
|
|
|
minetest.env:remove_node(pos)
|
2013-01-20 06:01:15 +01:00
|
|
|
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
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 06:01:15 +01:00
|
|
|
-- Code that spawns jungle trees and firs ("conifer")
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jt_axiom1 = "FFFA"
|
|
|
|
moretrees.jt_rules_a1 = "FFF[&&-FBf[&&&Ff]^^^Ff][&&+FBFf[&&&FFf]^^^Ff][&&---FBFf[&&&Ff]^^^Ff][&&+++FBFf[&&&Ff]^^^Ff]F/A"
|
|
|
|
moretrees.jt_rules_b1 = "[-Ff&f][+Ff&f]B"
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jt_axiom2 = "FFFFFA"
|
|
|
|
moretrees.jt_rules_a2 = "FFFFF[&&-FFFBF[&&&FFff]^^^FFf][&&+FFFBFF[&&&FFff]^^^FFf][&&---FFFBFF[&&&FFff]^^^FFf][&&+++FFFBFF[&&&FFff]^^^FFf]FF/A"
|
|
|
|
moretrees.jt_rules_b2 = "[-FFf&ff][+FFf&ff]B"
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.ct_rules_a1 = "FF[FF][&&-FBF][&&+FBF][&&---FBF][&&+++FBF]F/A"
|
|
|
|
moretrees.ct_rules_b1 = "[-FBf][+FBf]"
|
2013-01-11 16:29:38 +01:00
|
|
|
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.ct_rules_a2 = "FF[FF][&&-FBF][&&+FBF][&&---FBF][&&+++FBF]F/A"
|
|
|
|
moretrees.ct_rules_b2 = "[-fB][+fB]"
|
2013-01-10 03:35:50 +01:00
|
|
|
|
2013-01-19 06:45:03 +01:00
|
|
|
function moretrees:grow_jungletree(pos)
|
2013-01-11 16:29:38 +01:00
|
|
|
local r1 = math.random(2)
|
|
|
|
local r2 = math.random(3)
|
|
|
|
if r1 == 1 then
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jungletree_model.leaves2 = "jungletree:leaves_red"
|
2013-01-11 16:29:38 +01:00
|
|
|
else
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jungletree_model.leaves2 = "jungletree:leaves_yellow"
|
2013-01-11 16:29:38 +01:00
|
|
|
end
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jungletree_model.leaves2_chance = math.random(25, 75)
|
2013-01-11 16:29:38 +01:00
|
|
|
|
|
|
|
if r2 == 1 then
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jungletree_model.trunk_type = "single"
|
|
|
|
moretrees.jungletree_model.iterations = 2
|
|
|
|
moretrees.jungletree_model.axiom = moretrees.jt_axiom1
|
|
|
|
moretrees.jungletree_model.rules_a = moretrees.jt_rules_a1
|
|
|
|
moretrees.jungletree_model.rules_b = moretrees.jt_rules_b1
|
2013-01-11 16:29:38 +01:00
|
|
|
elseif r2 == 2 then
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jungletree_model.trunk_type = "double"
|
|
|
|
moretrees.jungletree_model.iterations = 4
|
|
|
|
moretrees.jungletree_model.axiom = moretrees.jt_axiom2
|
|
|
|
moretrees.jungletree_model.rules_a = moretrees.jt_rules_a2
|
|
|
|
moretrees.jungletree_model.rules_b = moretrees.jt_rules_b2
|
2013-01-11 16:29:38 +01:00
|
|
|
elseif r2 == 3 then
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.jungletree_model.trunk_type = "crossed"
|
|
|
|
moretrees.jungletree_model.iterations = 4
|
|
|
|
moretrees.jungletree_model.axiom = moretrees.jt_axiom2
|
|
|
|
moretrees.jungletree_model.rules_a = moretrees.jt_rules_a2
|
|
|
|
moretrees.jungletree_model.rules_b = moretrees.jt_rules_b2
|
2013-01-11 16:29:38 +01:00
|
|
|
end
|
|
|
|
|
2013-01-10 03:35:50 +01:00
|
|
|
minetest.env:remove_node(pos)
|
2013-01-11 16:29:38 +01:00
|
|
|
local leaves = minetest.env:find_nodes_in_area({x = pos.x-1, y = pos.y, z = pos.z-1}, {x = pos.x+1, y = pos.y+10, z = pos.z+1}, "default:leaves")
|
|
|
|
for leaf in ipairs(leaves) do
|
|
|
|
minetest.env:remove_node(leaves[leaf])
|
2013-01-10 03:35:50 +01:00
|
|
|
end
|
2013-01-20 00:36:13 +01:00
|
|
|
minetest.env:spawn_tree(pos, moretrees.jungletree_model)
|
2013-01-10 03:35:50 +01:00
|
|
|
end
|
|
|
|
|
2013-01-19 06:45:03 +01:00
|
|
|
function moretrees:grow_conifer(pos)
|
2013-01-11 16:29:38 +01:00
|
|
|
if math.random(2) == 1 then
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.conifer_model.leaves="conifers:leaves"
|
2013-01-11 16:29:38 +01:00
|
|
|
else
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.conifer_model.leaves="conifers:leaves_special"
|
2013-01-11 16:29:38 +01:00
|
|
|
end
|
|
|
|
if math.random(2) == 1 then
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.conifer_model.rules_a = moretrees.ct_rules_a1
|
|
|
|
moretrees.conifer_model.rules_b = moretrees.ct_rules_b1
|
2013-01-10 03:35:50 +01:00
|
|
|
else
|
2013-01-20 00:36:13 +01:00
|
|
|
moretrees.conifer_model.rules_a = moretrees.ct_rules_a2
|
|
|
|
moretrees.conifer_model.rules_b = moretrees.ct_rules_b2
|
2013-01-11 16:29:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.env:remove_node(pos)
|
|
|
|
local leaves = minetest.env:find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves")
|
|
|
|
for leaf in ipairs(leaves) do
|
|
|
|
minetest.env:remove_node(leaves[leaf])
|
2013-01-10 03:35:50 +01:00
|
|
|
end
|
2013-01-20 00:36:13 +01:00
|
|
|
minetest.env:spawn_tree(pos,moretrees.conifer_model)
|
2013-01-10 03:35:50 +01:00
|
|
|
end
|
|
|
|
|
2013-01-20 00:36:13 +01:00
|
|
|
|
2013-01-10 03:35:50 +01:00
|
|
|
|
|
|
|
-- Should we remove all the trees above the conifers altitude?
|
2013-01-20 00:36:13 +01:00
|
|
|
|
2013-01-10 03:35:50 +01:00
|
|
|
if CONIFERS_REMOVE_TREES == true then
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {
|
|
|
|
"default:tree",
|
|
|
|
"default:leaves"
|
|
|
|
},
|
|
|
|
interval = CONIFERS_RTREES_INTERVAL,
|
|
|
|
chance = CONIFERS_RTREES_CHANCE,
|
|
|
|
|
|
|
|
action = function(pos, node, _, _)
|
|
|
|
if minetest.env:get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air"
|
|
|
|
and pos.y >= CONIFERS_ALTITUDE
|
|
|
|
then
|
|
|
|
minetest.env:add_node(pos , {name = "air"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2013-01-19 03:35:39 +01:00
|
|
|
print("[Moretrees] Loaded (2013-01-18)")
|