Fix some bugs with the new sapling code and add legacy support for old saplings
This commit is contained in:
parent
45ad35e16c
commit
58e692bc65
|
@ -50,7 +50,21 @@ function default.place_sapling(itemstack, placer, pointed_thing)
|
|||
|
||||
minetest.set_node(pointed_thing.above, {name = itemstack:get_name()})
|
||||
|
||||
return itemstack:take_item()
|
||||
itemstack:take_item()
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
function default.begin_growing_sapling(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if node.name == "default:sapling" then
|
||||
minetest.get_node_timer(pos):start(math.random(300, 480))
|
||||
elseif node.name == "default:sapling_oak" then
|
||||
minetest.get_node_timer(pos):start(math.random(700, 960))
|
||||
elseif node.name == "default:sapling_birch" then
|
||||
minetest.get_node_timer(pos):start(math.random(480, 780))
|
||||
end
|
||||
end
|
||||
|
||||
function default.grow_sapling(pos, variety)
|
||||
|
@ -99,9 +113,23 @@ function default.grow_sapling(pos, variety)
|
|||
|
||||
minetest.after(0, grow)
|
||||
|
||||
default.log(variety.." tree sapling grows at "..minetest.pos_to_string(pos), "info")
|
||||
default.log("A " .. variety .. " tree sapling grows at " ..
|
||||
minetest.pos_to_string(pos), "info")
|
||||
end
|
||||
|
||||
-- Make preexisting trees restart the growing process
|
||||
|
||||
minetest.register_lbm(
|
||||
{
|
||||
label = "Grow legacy trees",
|
||||
name = "default:grow_legacy_trees",
|
||||
nodenames = {"default:sapling", "default:sapling_oak", "default:sapling_birch"},
|
||||
action = function(pos, node)
|
||||
default.begin_growing_sapling(pos)
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
-- Vertical plants
|
||||
|
||||
function default.dig_up(pos, node, digger)
|
||||
|
|
|
@ -448,7 +448,7 @@ minetest.register_node(
|
|||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(300, 480))
|
||||
default.begin_growing_sapling(pos)
|
||||
end,
|
||||
|
||||
on_place = default.place_sapling,
|
||||
|
@ -477,7 +477,7 @@ minetest.register_node(
|
|||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(700, 960))
|
||||
default.begin_growing_sapling(pos)
|
||||
end,
|
||||
|
||||
on_place = default.place_sapling,
|
||||
|
@ -507,7 +507,7 @@ minetest.register_node(
|
|||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(math.random(480, 780))
|
||||
default.begin_growing_sapling(pos)
|
||||
end,
|
||||
|
||||
on_place = default.place_sapling,
|
||||
|
|
Loading…
Reference in New Issue