summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crafts.lua130
-rw-r--r--init.lua103
-rw-r--r--leafdecay.lua69
-rw-r--r--node_defs.lua53
-rw-r--r--saplings.lua51
-rw-r--r--settings.lua22
6 files changed, 179 insertions, 249 deletions
diff --git a/crafts.lua b/crafts.lua
index 58f41fc..1baccd1 100644
--- a/crafts.lua
+++ b/crafts.lua
@@ -1,38 +1,40 @@
-for i in ipairs(moretrees.simple_trees) do
+for i in ipairs(moretrees.treelist) do
+ treename = moretrees.treelist[i][1]
+
minetest.register_craft({
- output = "moretrees:"..moretrees.simple_trees[i].."_trunk_sideways 2",
+ output = "moretrees:"..treename.."_trunk_sideways 2",
recipe = {
- {"moretrees:"..moretrees.simple_trees[i].."_trunk", "moretrees:"..moretrees.simple_trees[i].."_trunk"}
+ {"moretrees:"..treename.."_trunk", "moretrees:"..treename.."_trunk"}
}
})
minetest.register_craft({
- output = "moretrees:"..moretrees.simple_trees[i].."_trunk 2",
+ output = "moretrees:"..treename.."_trunk 2",
recipe = {
- {"moretrees:"..moretrees.simple_trees[i].."_trunk_sideways"},
- {"moretrees:"..moretrees.simple_trees[i].."_trunk_sideways"}
+ {"moretrees:"..treename.."_trunk_sideways"},
+ {"moretrees:"..treename.."_trunk_sideways"}
}
})
minetest.register_craft({
type = "shapeless",
- output = "moretrees:"..moretrees.simple_trees[i].."_planks 4",
+ output = "moretrees:"..treename.."_planks 4",
recipe = {
- "moretrees:"..moretrees.simple_trees[i].."_trunk"
+ "moretrees:"..treename.."_trunk"
}
})
minetest.register_craft({
type = "shapeless",
- output = "moretrees:"..moretrees.simple_trees[i].."_planks 4",
+ output = "moretrees:"..treename.."_planks 4",
recipe = {
- "moretrees:"..moretrees.simple_trees[i].."_trunk_sideways"
+ "moretrees:"..treename.."_trunk_sideways"
}
})
end
----- jungletrees
+-- extra crafting in case user has old jungle trees.
minetest.register_craft({
output = "moretrees:jungletree_trunk_sideways 2",
@@ -42,116 +44,10 @@ minetest.register_craft({
})
minetest.register_craft({
- output = "default:jungletree 2",
- recipe = {
- {"moretrees:jungletree_trunk_sideways"},
- {"moretrees:jungletree_trunk_sideways"}
- }
-})
-
-minetest.register_craft({
output = "moretrees:jungletree_planks 4",
recipe = {
{"default:jungletree"}
}
})
-minetest.register_craft({
- output = "moretrees:jungletree_planks 4",
- recipe = {
- {"moretrees:jungletree_trunk_sideways"}
- }
-})
-
----- firs
-minetest.register_craft({
- output = "moretrees:fir_trunk_sideways 2",
- recipe = {
- {"moretrees:fir_trunk", "moretrees:fir_trunk"},
- }
-})
-
-minetest.register_craft({
- output = "moretrees:fir_trunk 2",
- recipe = {
- {"moretrees:fir_trunk_sideways"},
- {"moretrees:fir_trunk_sideways"}
- }
-})
-
-minetest.register_craft({
- output = "moretrees:fir_planks 4",
- recipe = {
- {"moretrees:fir_trunk"}
- }
-})
-
-minetest.register_craft({
- output = "moretrees:fir_planks 4",
- recipe = {
- {"moretrees:fir_trunk_sideways"}
- }
-})
-
----- spruces
-
-minetest.register_craft({
- output = "moretrees:spruce_trunk_sideways 2",
- recipe = {
- {"moretrees:spruce_trunk", "moretrees:spruce_trunk"},
- }
-})
-
-minetest.register_craft({
- output = "moretrees:spruce_trunk 2",
- recipe = {
- {"moretrees:spruce_trunk_sideways"},
- {"moretrees:spruce_trunk_sideways"}
- }
-})
-
-minetest.register_craft({
- output = "moretrees:spruce_planks 4",
- recipe = {
- {"moretrees:spruce_trunk"}
- }
-})
-
-minetest.register_craft({
- output = "moretrees:spruce_planks 4",
- recipe = {
- {"moretrees:spruce_trunk_sideways"}
- }
-})
-
----- birches
-
-minetest.register_craft({
- output = "moretrees:birch_trunk_sideways 2",
- recipe = {
- {"moretrees:birch_trunk", "moretrees:birch_trunk"},
- }
-})
-
-minetest.register_craft({
- output = "moretrees:birch_trunk 2",
- recipe = {
- {"moretrees:birch_trunk_sideways"},
- {"moretrees:birch_trunk_sideways"}
- }
-})
-
-minetest.register_craft({
- output = "moretrees:birch_planks 4",
- recipe = {
- {"moretrees:birch_trunk"}
- }
-})
-
-minetest.register_craft({
- output = "moretrees:birch_planks 4",
- recipe = {
- {"moretrees:birch_trunk_sideways"}
- }
-})
diff --git a/init.lua b/init.lua
index 936c1d0..74b15dc 100644
--- a/init.lua
+++ b/init.lua
@@ -1,4 +1,4 @@
--- More trees! 2013-01-20
+-- More trees! 2013-02-11
--
-- This mod adds more types of trees to the game
--
@@ -8,35 +8,27 @@
-- Brought together into one mod and made L-systems compatible by Vanessa
-- Ezekowitz.
--
--- Conifers and Jungle tree axioms/rules by Vanessa Ezekowitz, with the
--- latter having been tweaked by RealBadAngel, most others written by
--- RealBadAngel.
---
--- License: WTFPL for all parts (code and textures)
---
-
--- snow biomes mod uses this code to make biomes:
---
--- 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
---
--- We'll just save this for possible later use ;-)
+-- Firs and Jungle tree axioms/rules by Vanessa Ezekowitz, with the
+-- latter having been tweaked by RealBadAngel, most other axioms/rules written
+-- by RealBadAngel.
--
+-- License: WTFPL for all parts (code and textures, including those copied
+-- from the jungletree and conifers mods) except the default jungle tree trunk
+-- texture, which is CC-By-SA.
moretrees = {}
-dofile(minetest.get_modpath("moretrees").."/settings.lua")
+-- These first two dofile() calls must precede any others, and must remain in
+-- this order, otherwise variables and node names will get skipped.
+dofile(minetest.get_modpath("moretrees").."/settings.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")
dofile(minetest.get_modpath("moretrees").."/crafts.lua")
dofile(minetest.get_modpath("moretrees").."/leafdecay.lua")
+dofile(minetest.get_modpath("moretrees").."/saplings.lua")
-- tree spawning setup
@@ -53,56 +45,6 @@ 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.fir_biome, "moretrees:grow_fir")
--- sapling growth
-
-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"
-
- plantslib:dbg(dump(moretrees[tree_biome].surface))
-
- plantslib:grow_plants({
- grow_delay = moretrees.sapling_interval,
- grow_chance = moretrees.sapling_chance,
- grow_plant = "moretrees:"..tree_name.."_sapling",
- grow_nodes = moretrees[tree_biome].surface,
- grow_function = moretrees[tree_model],
- })
-end
-
-plantslib:grow_plants({
- grow_delay = moretrees.sapling_interval,
- grow_chance = moretrees.sapling_chance,
- grow_plant = "moretrees:birch_sapling",
- grow_nodes = moretrees.birch_biome.surface,
- grow_function = "moretrees:grow_birch"
-})
-
-plantslib:grow_plants({
- grow_delay = moretrees.sapling_interval,
- grow_chance = moretrees.sapling_chance,
- grow_plant = "moretrees:spruce_sapling",
- grow_nodes = moretrees.spruce_biome.surface,
- grow_function = "moretrees:grow_spruce"
-})
-
-plantslib:grow_plants({
- grow_delay = moretrees.sapling_interval,
- grow_chance = moretrees.sapling_chance,
- grow_plant = "moretrees:fir_sapling",
- grow_nodes = moretrees.fir_biome.surface,
- grow_function = "moretrees:grow_fir"
-})
-
-plantslib:grow_plants({
- grow_delay = moretrees.sapling_interval,
- grow_chance = moretrees.sapling_chance,
- grow_plant = "moretrees:jungletree_sapling",
- grow_nodes = moretrees.jungletree_biome.surface,
- grow_function = "moretrees:grow_jungletree"
-})
-
-- Code to spawn a birch tree
function moretrees:grow_birch(pos)
@@ -125,7 +67,7 @@ function moretrees:grow_spruce(pos)
end
end
--- Code that spawns jungle trees and firs
+-- Code to spawn jungle trees
moretrees.jt_axiom1 = "FFFA"
moretrees.jt_rules_a1 = "FFF[&&-FBf[&&&Ff]^^^Ff][&&+FBFf[&&&FFf]^^^Ff][&&---FBFf[&&&Ff]^^^Ff][&&+++FBFf[&&&Ff]^^^Ff]F/A"
@@ -179,6 +121,8 @@ function moretrees:grow_jungletree(pos)
minetest.env:spawn_tree(pos, moretrees.jungletree_model)
end
+-- code to spawn fir trees (formerly "conifers")
+
function moretrees:grow_fir(pos)
if math.random(2) == 1 then
moretrees.fir_model.leaves="moretrees:fir_leaves"
@@ -201,8 +145,6 @@ function moretrees:grow_fir(pos)
minetest.env:spawn_tree(pos,moretrees.fir_model)
end
-
-
-- Should we remove all the trees above the conifers altitude?
if moretrees.firs_remove_default_trees == true then
@@ -224,4 +166,17 @@ if moretrees.firs_remove_default_trees == true then
})
end
-print("[Moretrees] Loaded (2013-01-18)")
+-- snow biomes mod uses this code to make biomes:
+--
+-- 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
+--
+-- We'll just save this for possible later use ;-)
+--
+
+print("[Moretrees] Loaded (2013-02-11)")
diff --git a/leafdecay.lua b/leafdecay.lua
index cab0281..1870cb6 100644
--- a/leafdecay.lua
+++ b/leafdecay.lua
@@ -1,34 +1,65 @@
-- leaf decay
-minetest.register_abm({
- nodenames = moretrees.leaves_list,
- interval = moretrees.leafdecay_delay,
- chance = moretrees.leafdecay_chance,
- action = function(pos, node, active_object_count, active_object_count_wider)
- if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, moretrees.trunks_list) then
- minetest.env:remove_node(pos)
- minetest.env:dig_node(pos)
+if moretrees.enable_leafdecay then
+ for i in ipairs(moretrees.treelist) do
+ local treename = moretrees.treelist[i][1]
+ if treename ~= "jungletree" and treename ~= "fir" then
+ minetest.register_abm({
+ nodenames = "moretrees:"..treename.."_leaves",
+ interval = moretrees.leafdecay_delay,
+ chance = moretrees.leafdecay_chance,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, "moretrees:"..treename.."_trunk") then
+ minetest.env:remove_node(pos)
+ minetest.env:dig_node(pos)
+ end
+ end
+ })
end
end
-})
-minetest.register_abm({
- nodenames = "moretrees:palm_leaves",
- interval = moretrees.leafdecay_delay,
- chance = moretrees.leafdecay_chance,
- action = function(pos, node, active_object_count, active_object_count_wider)
- if not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, moretrees.trunks_list) then
- minetest.env:remove_node(pos)
- minetest.env:dig_node(pos)
+ minetest.register_abm({
+ nodenames = {"moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_green","moretrees:jungletree_leaves_yellow"},
+ interval = moretrees.leafdecay_delay,
+ chance = moretrees.leafdecay_chance,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, {"default:jungletree", "moretrees:jungletree_trunk"}) then
+ minetest.env:remove_node(pos)
+ minetest.env:dig_node(pos)
+ end
end
- end
-})
+ })
+ minetest.register_abm({
+ nodenames = {"moretrees:fir_leaves", "moretrees:fir_leaves_bright"},
+ interval = moretrees.leafdecay_delay,
+ chance = moretrees.leafdecay_chance,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if not minetest.env:find_node_near(pos, moretrees.leafdecay_radius, "moretrees:fir_trunk") then
+ minetest.env:remove_node(pos)
+ minetest.env:dig_node(pos)
+ end
+ end
+ })
+
+ minetest.register_abm({
+ nodenames = "moretrees:palm_leaves",
+ interval = moretrees.leafdecay_delay,
+ chance = moretrees.leafdecay_chance,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if not minetest.env:find_node_near(pos, moretrees.palm_leafdecay_radius, "moretrees:palm_trunk") then
+ minetest.env:remove_node(pos)
+ minetest.env:dig_node(pos)
+ end
+ end
+ })
+end
if moretrees.enable_replace_default_trees then
minetest.register_alias("mapgen_tree", "air")
minetest.register_alias("mapgen_leaves", "air")
plantslib:register_generate_plant(moretrees.beech_biome, moretrees.beech_model)
+
elseif moretrees.enable_default_leafdecay then
minetest.register_abm({
nodenames = "default:leaves",
diff --git a/node_defs.lua b/node_defs.lua
index 858f5af..1f14f4e 100644
--- a/node_defs.lua
+++ b/node_defs.lua
@@ -1,15 +1,6 @@
moretrees.avoidnodes = {}
-
-table.insert(moretrees.avoidnodes, "default:jungletree")
-table.insert(moretrees.avoidnodes, "moretrees:jungletree_trunk")
-table.insert(moretrees.avoidnodes, "moretrees:jungletree_leaves_red")
-table.insert(moretrees.avoidnodes, "moretrees:jungletree_leaves_green")
-table.insert(moretrees.avoidnodes, "moretrees:jungletree_leaves_yellow")
-table.insert(moretrees.avoidnodes, "moretrees:fir_trunk")
-table.insert(moretrees.avoidnodes, "moretrees:fir_leaves")
-table.insert(moretrees.avoidnodes, "moretrees:fir_leaves_bright")
-trees = {
+moretrees.treelist = {
{"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 },
@@ -24,18 +15,13 @@ trees = {
{"fir", "Douglas Fir", "fir_cone", "Fir Cone", {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 },
}
-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 fruit = trees[i][3]
- local fruitdesc = trees[i][4]
- local selbox = trees[i][5]
- local vscale = trees[i][6]
+for i in ipairs(moretrees.treelist) do
+ local treename = moretrees.treelist[i][1]
+ local treedesc = moretrees.treelist[i][2]
+ local fruit = moretrees.treelist[i][3]
+ local fruitdesc = moretrees.treelist[i][4]
+ local selbox = moretrees.treelist[i][5]
+ local vscale = moretrees.treelist[i][6]
minetest.register_node("moretrees:"..treename.."_trunk", {
@@ -134,13 +120,7 @@ for i in ipairs(trees) do
table.insert(moretrees.avoidnodes, "moretrees:"..treename.."_trunk")
table.insert(moretrees.avoidnodes, "moretrees:"..treename.."_leaves")
- table.insert(moretrees.trunks_list, "moretrees:"..treename.."_trunk")
- if treename ~= "palm" then
- table.insert(moretrees.leaves_list, "moretrees:"..treename.."_leaves")
- end
-
end
-table.insert(moretrees.trunks_list, "default:jungletree")
-- Extra leaves for jungle trees:
@@ -163,7 +143,6 @@ 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
@@ -184,7 +163,6 @@ minetest.register_node("moretrees:fir_leaves_bright", {
},
sounds = default.node_sound_leaves_defaults()
})
-table.insert(moretrees.leaves_list, "moretrees:fir_leaves_bright")
if moretrees.enable_redefine_apple then
minetest.register_node(":default:apple", {
@@ -206,11 +184,24 @@ if moretrees.enable_redefine_apple then
})
end
-
+table.insert(moretrees.avoidnodes, "default:jungletree")
+table.insert(moretrees.avoidnodes, "moretrees:jungletree_trunk")
+table.insert(moretrees.avoidnodes, "moretrees:jungletree_leaves_red")
+table.insert(moretrees.avoidnodes, "moretrees:jungletree_leaves_green")
+table.insert(moretrees.avoidnodes, "moretrees:jungletree_leaves_yellow")
+table.insert(moretrees.avoidnodes, "moretrees:fir_trunk")
+table.insert(moretrees.avoidnodes, "moretrees:fir_leaves")
+table.insert(moretrees.avoidnodes, "moretrees:fir_leaves_bright")
-- Backward compatbility with old mods/nodes:
+minetest.registered_items["jungletree"] = nil
+minetest.registered_aliases["jungletree"] = nil
+minetest.registered_items["default:jungletree"] = nil
+minetest.registered_aliases["default:jungletree"] = nil
+minetest.register_alias("jungletree", "moretrees:jungletree_trunk")
minetest.register_alias("default:jungletree", "moretrees:jungletree_trunk")
+
minetest.register_alias("jungletree:leaves_green", "moretrees:jungletree_leaves_green")
minetest.register_alias("jungletree:leaves_red", "moretrees:jungletree_leaves_red")
minetest.register_alias("jungletree:leaves_yellow", "moretrees:jungletree_leaves_yellow")
diff --git a/saplings.lua b/saplings.lua
new file mode 100644
index 0000000..5d0af28
--- /dev/null
+++ b/saplings.lua
@@ -0,0 +1,51 @@
+-- sapling growth
+
+for i in ipairs(moretrees.treelist) do
+ local treename = moretrees.treelist[i][1]
+ local tree_model = treename.."_model"
+ local tree_biome = treename.."_biome"
+
+ if treename ~= "birch" and treename ~= "spruce" and treename ~= "fir" and treename ~= "jungletree" then
+
+ plantslib:dbg(dump(moretrees[tree_biome].surface))
+ plantslib:grow_plants({
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
+ grow_plant = "moretrees:"..treename.."_sapling",
+ grow_nodes = moretrees[tree_biome].surface,
+ grow_function = moretrees[tree_model],
+ })
+ end
+end
+
+plantslib:grow_plants({
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
+ grow_plant = "moretrees:birch_sapling",
+ grow_nodes = moretrees.birch_biome.surface,
+ grow_function = "moretrees:grow_birch"
+})
+
+plantslib:grow_plants({
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
+ grow_plant = "moretrees:spruce_sapling",
+ grow_nodes = moretrees.spruce_biome.surface,
+ grow_function = "moretrees:grow_spruce"
+})
+
+plantslib:grow_plants({
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
+ grow_plant = "moretrees:fir_sapling",
+ grow_nodes = moretrees.fir_biome.surface,
+ grow_function = "moretrees:grow_fir"
+})
+
+plantslib:grow_plants({
+ grow_delay = moretrees.sapling_interval,
+ grow_chance = moretrees.sapling_chance,
+ grow_plant = "moretrees:jungletree_sapling",
+ grow_nodes = moretrees.jungletree_biome.surface,
+ grow_function = "moretrees:grow_jungletree"
+})
diff --git a/settings.lua b/settings.lua
index f9974ef..85a3a5d 100644
--- a/settings.lua
+++ b/settings.lua
@@ -1,4 +1,4 @@
--- Configuration variables
+-- Global configuration variables
-- Enable replacement of default trees with birch if you want but be warned -
-- due to bugs in the speed of the engine's map generator/loader, doing so\
@@ -6,11 +6,17 @@
moretrees.enable_replace_default_trees = false
--- Enable the first one if you want this mod's leafdecay code to affect the
--- old default trees. You'll want to manually disable the default leafdecay
--- code in minetest_game if you enable this.
+-- Set this to true to enable leaf decay of all trees except the default ones.
-moretrees.enable_default_leafdecay = false
+moretrees.enable_leafdecay = true
+
+-- Enable this one if you want this mod's leafdecay code to affect the old
+-- default trees too; this setting is independent of the one above. You'll
+-- want to manually disable the default leafdecay code in minetest_game if
+-- you enable this, otherwise you'll have two sets of leaf decay code running
+-- at the same time, which will just waste CPU for no benefit.
+
+moretrees.enable_default_leafdecay = true
-- Enable this if you want moretrees to redefine default apples so that they
-- fall when leaves decay/are dug.
@@ -20,13 +26,13 @@ moretrees.enable_redefine_apple = true
-- various settings to configure leaf decay in general.
moretrees.leafdecay_delay = 2
-moretrees.leafdecay_chance = 150
+moretrees.leafdecay_chance = 200
moretrees.leafdecay_radius = 5
moretrees.palm_leafdecay_radius = 8
-moretrees.default_leafdecay_delay = 2
-moretrees.default_leafdecay_chance = 50
+moretrees.default_leafdecay_delay = 3
+moretrees.default_leafdecay_chance = 100
moretrees.default_leafdecay_radius = 4
-- Change these settings if you want default trees to be gradually cut down