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

finished splitting up the three components into separate folders, by moving

texture files to their respective components' folders (<f>/textures).  Also,
began working on extending the API for the growing code to allow for checking
for the height of a node.  Poisonivy is the only component that uses it for
now; this is more intended to be used with nature pack eventually.
This commit is contained in:
Vanessa Ezekowitz 2012-12-09 22:02:30 -05:00
parent 01270a26f0
commit 7006416227
27 changed files with 50 additions and 11 deletions

18
API.txt
View File

@ -72,8 +72,9 @@ depthmax: If a node spawns on top of a water source, the water must be at
-----
The second function, grow_plants() is defined like so:
grow_plants = function(gdelay, gchance, gplant, gresult,
dry_early_node, grow_nodes)
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node,
grow_nodes, facedir, need_wall, grow_vertically, height_limit,
ground_nodes)
gdelay: Passed as the ABM "interval" parameter, as with spawning.
gchance: Passed as the ABM "chance" parameter.
@ -97,6 +98,19 @@ grow_nodes: This node must be under the plant in order for it to grow at
facedir: Same as with spawning a plant. If supplied, this value is
passed to the param2 variable when changing the plant. If nil
or left out, no new param2 value is applied.
need_wall: Set this to true if you the plant needs to grow against a
wall. Defaults to false.
grow_vertically: Set this to true if the plant needs to grow vertically, as in
climbing poison ivy. Defaults to false.
height_limit: Just how tall can a vertically-growing plant go? Set this
accordingly. The mod will search straight down from the
position being spawned at to find a ground node, below.
Defaults to 62000 (unlimited).
ground_nodes: What nodes should be treated as "the ground" below a
vertically-growing plant. Usually this will be the same as
the grow_nodes table, but might also include, for example,
water or some other surrounding material. Defaults to
"default:dirt_with_grass".
-----
plant_valid_wall() expects only a single parameter, "pos", which is a table

View File

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 680 B

View File

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 315 B

View File

Before

Width:  |  Height:  |  Size: 498 B

After

Width:  |  Height:  |  Size: 498 B

View File

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 169 B

View File

Before

Width:  |  Height:  |  Size: 464 B

After

Width:  |  Height:  |  Size: 464 B

View File

Before

Width:  |  Height:  |  Size: 166 B

After

Width:  |  Height:  |  Size: 166 B

View File

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 462 B

View File

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 361 B

View File

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 520 B

View File

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 405 B

View File

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

View File

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 479 B

View File

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 416 B

View File

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 159 B

View File

Before

Width:  |  Height:  |  Size: 470 B

After

Width:  |  Height:  |  Size: 470 B

View File

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 140 B

View File

Before

Width:  |  Height:  |  Size: 465 B

After

Width:  |  Height:  |  Size: 465 B

View File

Before

Width:  |  Height:  |  Size: 221 B

After

Width:  |  Height:  |  Size: 221 B

View File

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

View File

Before

Width:  |  Height:  |  Size: 370 B

After

Width:  |  Height:  |  Size: 370 B

View File

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 325 B

View File

@ -90,7 +90,11 @@ end
-- The growing ABM
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_nodes, facedir)
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_nodes, facedir, need_wall, grow_vertically, height_limit, ground_nodes)
if need_wall ~= true then need_wall = false end
if grow_vertically ~= true then grow_vertically = false end
if height_limit == nil then height_limit = 62000 end
if ground_node == nil then ground_nodes = { "default:dirt_with_grass" } end
minetest.register_abm({
nodenames = { gplant },
interval = gdelay,
@ -100,15 +104,21 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
local p_bot = {x=pos.x, y=pos.y-1, z=pos.z}
local n_top = minetest.env:get_node(p_top)
local n_bot = minetest.env:get_node(p_bot)
local groundnode = minetest.env:get_node({x=pos.x, y=pos.y-height_limit, z=pos.z})
if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air" then
-- corner case for wall-climbing poison ivy
if gplant == "poisonivy:climbing" then
local walldir=plant_valid_wall(p_top)
if walldir ~= nil then
dbg("Grow: "..gplant.." upwards to ("..dump(p_top)..")")
minetest.env:add_node(p_top, { name = gplant, param2 = walldir })
if grow_vertically then
if find_first_node(pos, height_limit, ground_nodes) ~= nil then
if need_wall then
local walldir=plant_valid_wall(p_top)
if walldir ~= nil then
dbg("Grow: "..gplant.." upwards to ("..dump(p_top)..") on wall "..walldir)
minetest.env:add_node(p_top, { name = gplant, param2 = walldir })
end
else
dbg("Grow: "..gplant.." upwards to ("..dump(p_top)..")")
minetest.env:add_node(p_top, { name = gplant })
end
end
-- corner case for changing short junglegrass to dry shrub in desert
@ -155,6 +165,19 @@ plant_valid_wall = function(wallpos)
return walldir
end
-- Function to search straight down from (pos) to find first node in match list.
find_first_node = function(pos, height_limit, nodelist)
for i = 1, height_limit do
n = minetest.env:get_node({x=pos.x, y=pos.y-i, z=pos.z})
if string.find(dump(nodelist),n.name) ~= nil then
return n.name
end
end
return nil
end
local enstr = ""
if enabled_flowers then enstr = enstr.." flowers" end

View File

@ -63,7 +63,9 @@ minetest.register_node(':poisonivy:climbing', {
})
spawn_on_surfaces(spawn_delay, "poisonivy:seedling", 10 , spawn_chance/10, "default:dirt_with_grass", {"group:poisonivy","group:flower"}, poisonivy_seed_diff, 7)
grow_plants(spawn_delay, grow_chance, "poisonivy:seedling", "poisonivy:sproutling", nil, {"default:dirt_with_grass"})
grow_plants(spawn_delay, grow_chance*2, "poisonivy:climbing", nil, nil, nil)
grow_plants(spawn_delay, grow_chance*2, "poisonivy:climbing", nil, nil, nil ,nil,true,true,nil,{"default:dirt_with_grass"})
enabled_poisonivy = true

View File

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 456 B

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 426 B