routed spawn_tree() through a wrapper function so that other mods can hook into

plants_lib's calls to do something extra when a tree is generated at mapgen
time or spawned via the growing code.
This commit is contained in:
Vanessa Ezekowitz
2013-02-19 21:50:56 -05:00
parent a86c52cfa8
commit 6bfb454178
2 changed files with 21 additions and 2 deletions

View File

@ -133,7 +133,7 @@ function plantslib:search_for_surfaces(minp, maxp, biomedef, node_or_function_or
end
]]--
minetest.env:spawn_tree(pos, node_or_function_or_model)
plantslib:generate_tree(pos, node_or_function_or_model)
elseif type(node_or_function_or_model) == "string" then
if minetest.registered_nodes[node_or_function_or_model] == nil then
@ -353,7 +353,7 @@ function plantslib:replace_object(pos, replacement, grow_function, walldir, seed
if growtype == "table" then
plantslib:dbg("Grow: spawn tree at "..dump(pos))
minetest.env:remove_node(pos)
minetest.env:spawn_tree(pos, grow_function)
plantslib:grow_tree(pos, grow_function)
return
elseif growtype == "string" then
local perlin1 = minetest.env:get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale)
@ -418,4 +418,17 @@ function plantslib:find_open_side(pos)
return nil
end
-- spawn_tree() on generate is routed through here so that other mods can hook
-- into it.
function plantslib:generate_tree(pos, node_or_function_or_model)
minetest.env:spawn_tree(pos, node_or_function_or_model)
end
-- and this one's for the call used in the growing code
function plantslib:grow_tree(pos, node_or_function_or_model)
minetest.env:spawn_tree(pos, node_or_function_or_model)
end
print("[Plantlife Library] Loaded")