rework how sapling growth is defined

if on-gen, saplings grow per their biome_defs.lua settings
if placed, they grow on the surfaces given in the tables:

* anything but palms will grow on the dirt surfaces
* conifers can also grow on a cold surface, but other trees will not
* only palms can grow on sand, but they will not grow on dirt or cold
This commit is contained in:
Vanessa Dannenberg 2019-05-22 19:09:41 -04:00
parent a27af10d2e
commit 7161cfbdee

View File

@ -1,98 +1,75 @@
-- sapling growth
-- these tables only affect hand-placed saplings
-- mapgen-placed always use their biome def settings, which are much more
-- limited, in the interest of speed.
local dirt_surfaces = {
"default:dirt",
"default:dirt_with_grass",
"default:dirt_with_dry_grass",
"default:dirt_with_coniferous_litter",
"default:dirt_with_rainforest_litter",
"default:dirt_with_snow",
"woodsoils:dirt_with_leaves_1",
"woodsoils:dirt_with_leaves_2",
"woodsoils:grass_with_leaves_1",
"woodsoils:grass_with_leaves_2"
}
local cold_surfaces = {
"default:dirt_with_snow"
}
local sand_surfaces = {
"default:sand",
"default:desert_sand",
"cottages:loam",
-- note, no silver sand here.
-- too cold for a palm, too... well... sandy for anything else.
}
for i in ipairs(moretrees.treelist) do
local treename = moretrees.treelist[i][1]
local tree_model = treename.."_model"
local tree_biome = treename.."_biome"
local surfaces
local grow_function = moretrees[tree_model]
if treename ~= "birch" and treename ~= "spruce" and treename ~= "fir" and treename ~= "jungletree" then
if treename == "spruce"
or treename == "fir"
or treename == "cedar"
or treename == "pine" then
surfaces = cold_surfaces
elseif string.find(treename, "palm") then
surfaces = sand_surfaces
else
surfaces = dirt_surfaces
end
biome_lib:dbg(dump(moretrees[tree_biome].surface))
if treename == "spruce"
or treename == "fir"
or treename == "birch"
or treename == "jungletree" then
grow_function = "moretrees.grow_"..treename
end
biome_lib:dbg(dump(moretrees[tree_biome].surface))
biome_lib:grow_plants({
grow_delay = moretrees.sapling_interval,
grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:"..treename.."_sapling",
grow_nodes = surfaces,
grow_function = grow_function,
})
if moretrees.spawn_saplings then
biome_lib:grow_plants({
grow_delay = moretrees.sapling_interval,
grow_chance = moretrees.sapling_chance,
grow_plant = "moretrees:"..treename.."_sapling",
grow_delay = 2,
grow_chance = 2,
grow_plant = "moretrees:"..treename.."_sapling_ongen",
grow_nodes = moretrees[tree_biome].surface,
grow_function = moretrees[tree_model],
grow_function = grow_function,
})
if moretrees.spawn_saplings then
biome_lib:grow_plants({
grow_delay = 2,
grow_chance = 2,
grow_plant = "moretrees:"..treename.."_sapling_ongen",
grow_nodes = moretrees[tree_biome].surface,
grow_function = moretrees[tree_model],
})
end
end
end
biome_lib: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"
})
biome_lib: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"
})
biome_lib: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"
})
biome_lib:grow_plants({
grow_delay = moretrees.sapling_interval,
grow_chance = moretrees.sapling_chance,
grow_plant = "default:junglesapling",
grow_nodes = moretrees.jungletree_biome.surface,
grow_function = "moretrees.grow_jungletree"
})
if moretrees.spawn_saplings then
biome_lib:grow_plants({
grow_delay = 2,
grow_chance = 30,
grow_plant = "moretrees:jungletree_sapling_ongen",
grow_nodes = moretrees.jungletree_biome.surface,
grow_function = "moretrees.grow_jungletree"
})
biome_lib:grow_plants({
grow_delay = 2,
grow_chance = 30,
grow_plant = "moretrees:fir_sapling_ongen",
grow_nodes = moretrees.fir_biome.surface,
grow_function = "moretrees.grow_fir"
})
biome_lib:grow_plants({
grow_delay = 2,
grow_chance = 30,
grow_plant = "moretrees:spruce_sapling_ongen",
grow_nodes = moretrees.spruce_biome.surface,
grow_function = "moretrees.grow_spruce"
})
biome_lib:grow_plants({
grow_delay = 2,
grow_chance = 30,
grow_plant = "moretrees:birch_sapling_ongen",
grow_nodes = moretrees.birch_biome.surface,
grow_function = "moretrees.grow_birch"
})
end