forked from mtcontrib/biome_lib
Using ":" notation to treat functions as methods is now deprecated
in favor of more normal "." notation. In the process, I have renamed a few functions in favor of more meaningful names (see API.txt), and provided "compatibility shims" for old mods where needed, with warnings.
This commit is contained in:
24
growth.lua
24
growth.lua
@ -15,7 +15,7 @@ function biome_lib.check_surface(name, nodes)
|
||||
return false
|
||||
end
|
||||
|
||||
function biome_lib:grow_plants(opts)
|
||||
function biome_lib.update_plant(opts)
|
||||
|
||||
local options = opts
|
||||
|
||||
@ -32,7 +32,7 @@ function biome_lib:grow_plants(opts)
|
||||
n = options.grow_plant
|
||||
end
|
||||
|
||||
options.label = options.label or "biome_lib grow_plants(): "..n
|
||||
options.label = options.label or "biome_lib.update_plant(): "..n
|
||||
|
||||
if options.grow_delay*time_scale >= 1 then
|
||||
options.interval = options.grow_delay*time_scale
|
||||
@ -53,12 +53,12 @@ function biome_lib:grow_plants(opts)
|
||||
local root_node = minetest.get_node({x=pos.x, y=pos.y-options.height_limit, z=pos.z})
|
||||
local walldir = nil
|
||||
if options.need_wall and options.verticals_list then
|
||||
walldir = biome_lib:find_adjacent_wall(p_top, options.verticals_list, options.choose_random_wall)
|
||||
walldir = biome_lib.find_adjacent_wall(p_top, options.verticals_list, options.choose_random_wall)
|
||||
end
|
||||
if biome_lib.default_grow_through_nodes[n_top.name]
|
||||
and (not options.need_wall or (options.need_wall and walldir)) then
|
||||
if options.grow_vertically and walldir then
|
||||
if biome_lib:search_downward(pos, options.height_limit, options.ground_nodes) then
|
||||
if biome_lib.search_downward(pos, options.height_limit, options.ground_nodes) then
|
||||
minetest.swap_node(p_top, { name = options.grow_plant, param2 = walldir})
|
||||
end
|
||||
|
||||
@ -67,24 +67,10 @@ function biome_lib:grow_plants(opts)
|
||||
minetest.swap_node(pos, biome_lib.air)
|
||||
|
||||
else
|
||||
biome_lib:replace_object(pos, options.grow_result, options.grow_function, options.facedir, options.seed_diff)
|
||||
biome_lib.replace_plant(pos, options.grow_result, options.grow_function, options.facedir, options.seed_diff)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- spawn_tree() on generate is routed through here so that other mods can hook
|
||||
-- into it.
|
||||
|
||||
function biome_lib:generate_tree(pos, nodes_or_function_or_model)
|
||||
minetest.spawn_tree(pos, nodes_or_function_or_model)
|
||||
end
|
||||
|
||||
-- and this one's for the call used in the growing code
|
||||
|
||||
function biome_lib:grow_tree(pos, nodes_or_function_or_model)
|
||||
minetest.spawn_tree(pos, nodes_or_function_or_model)
|
||||
end
|
||||
|
Reference in New Issue
Block a user