1
0
mirror of https://github.com/mt-mods/plantlife_modpack.git synced 2024-11-05 09:50:27 +01:00

Fixed a bug in direct growing of trees

This commit is contained in:
Vanessa Ezekowitz 2013-01-20 13:37:58 -05:00
parent 40b4cc677a
commit 34b7ad4f32
2 changed files with 23 additions and 18 deletions

31
API.txt
View File

@ -184,7 +184,7 @@ defined like so:
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node,
grow_nodes, facedir, need_wall, grow_vertically, height_limit, grow_nodes, facedir, need_wall, grow_vertically, height_limit,
ground_nodes, grow_function) ground_nodes, grow_function, seed_diff)
gdelay: Passed as the ABM "interval" parameter, as with spawning. gdelay: Passed as the ABM "interval" parameter, as with spawning.
gchance: Passed as the ABM "chance" parameter. gchance: Passed as the ABM "chance" parameter.
@ -221,21 +221,20 @@ ground_nodes: What nodes should be treated as "the ground" below a
as the grow_nodes table, but might also include, for as the grow_nodes table, but might also include, for
example, water or some other surrounding material. example, water or some other surrounding material.
Defaults to "default:dirt_with_grass". Defaults to "default:dirt_with_grass".
grow_function: Execute the named function (which must be supplied as just grow_function: String indicating what function to use to grow the plant, if
the name of the function as a string) when growing this any, or a table with an L-Systems tree model, or nil. If it's
node, rather than using the method provided by the default nil, If it's nil, a regular plant will be inserted in place
growing code. Note that if this is specified, only the of the one being grown, per the above variables. If it's a
gdelay, gchance, and gplant variables will be used, the string, the function named therein is executed and passed a
rest will be ignored by the growing ABM. You can still parameter for the current position, followed by the "can grow
read them from within the function if you need to. The here" and temperature map Perlin values at that location. If
function will be passed two parameters in order: The it's a table, the tree described by that table is spawned at
position of the node to be "grown" (in the usual table the current position. In both cases, all parameters from
format), and the Perlin noise value at the location in gresult to ground_nodes are ignored.
question. seed_diff: The Perlin seed diff to be use to calculate the first noise
seed_diff: The Perlin seed diff to be use to calculate the noise value given to the above grow_function. Should be the same as
value given to the above grow_function. Should be the the seed diff used when first spawning the plant that's being
same as the seed diff used when first spawning the plant grown.
that's being grown.
----- -----

View File

@ -258,8 +258,14 @@ function plantslib:grow_plants(
local perlin2 = minetest.env:get_perlin(temperature_seeddiff, temperature_octaves, temperature_persistence, temperature_scale) local perlin2 = minetest.env:get_perlin(temperature_seeddiff, temperature_octaves, temperature_persistence, temperature_scale)
local noise1 = perlin1:get2d({x=p_top.x, y=p_top.z}) local noise1 = perlin1:get2d({x=p_top.x, y=p_top.z})
local noise2 = perlin2:get2d({x=p_top.x, y=p_top.z}) local noise2 = perlin2:get2d({x=p_top.x, y=p_top.z})
minetest.log("verbose", "Call function: "..grow_function.."("..dump(pos)..","..noise1..","..noise2..")") if type(grow_function) == "table" then
assert(loadstring(grow_function.."("..dump(pos)..","..noise1..","..noise2..")"))() minetest.log("verbose", "Grow sapling into tree at "..dump(pos))
minetest.env:remove_node(pos)
minetest.env:spawn_tree(pos, grow_function)
else
minetest.log("verbose", "Call function: "..grow_function.."("..dump(pos)..","..noise1..","..noise2..")")
assert(loadstring(grow_function.."("..dump(pos)..","..noise1..","..noise2..")"))()
end
end end
end end
}) })