improve sapling/root growth.
trees will now create a living root node at their bottom when they grow for the first time.
This commit is contained in:
parent
f31940ffa5
commit
f4d8c7597d
1 changed files with 14 additions and 2 deletions
|
@ -5,7 +5,6 @@ local modname = minetest.get_current_modname()
|
|||
local sapling = modname .. ":sapling"
|
||||
local log_alive = modname .. ":log_alive"
|
||||
local leaves_growing = modname .. ":leaves_growing"
|
||||
local root_alive = modname .. ":root_alive"
|
||||
|
||||
-- END OF NODE NAMES
|
||||
|
||||
|
@ -42,11 +41,24 @@ blockgame.register_increasing_abm({
|
|||
-- (this will require the api adding support for increasing_abm actions modifying their data.)
|
||||
local above = pos + blockgame.vector.dirs.up
|
||||
|
||||
-- grow up, with a chance to stop growing.
|
||||
if not blockgame.chance(4) then
|
||||
minetest.set_node(above, {name = sapling})
|
||||
end
|
||||
minetest.set_node(pos, {name = log_alive})
|
||||
|
||||
local below = pos + blockgame.vector.dirs.down
|
||||
-- if this tree have already grown at least once, create a log...
|
||||
if blockgame.item_matches(minetest.get_node(below).name, {
|
||||
modname .. ":root_alive",
|
||||
modname .. ":log_alive",
|
||||
}) then
|
||||
minetest.set_node(pos, {name = log_alive})
|
||||
else
|
||||
-- ... otherwise, create a root
|
||||
minetest.set_node(pos, {name = modname .. ":root_alive"})
|
||||
end
|
||||
|
||||
-- grow out leaves to the sides.
|
||||
local sides = blockgame.vector.get_sides_of(pos)
|
||||
for _, side in pairs(sides) do
|
||||
blockgame.attempt_place(side, {name = leaves_growing})
|
||||
|
|
Loading…
Reference in a new issue