Fixed a bug in the placement of seaweed, fixing it extends the API slightly.

Updated API.txt accordingly.
This commit is contained in:
Vanessa Ezekowitz 2012-12-02 02:09:31 -05:00
parent 13534d1631
commit e3a9d05871
3 changed files with 23 additions and 12 deletions

View File

@ -17,7 +17,8 @@ The first of these, spawn_on_surfaces() is defined with quite a large number
of variables:
spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface,
savoid, seed_diff, lightmin, lightmax, nneighbors, ocount)
savoid, seed_diff, lightmin, lightmax, nneighbors,
ocount, facedir)
The first several of these are all required, and are from the last version of
the flowers mod, so this part of the API should be the same as before.
@ -63,6 +64,8 @@ nneighbors: Table with a list of neighboring nodes, passed to the ABM as the
ocount: There must be at least this many of the above neighbors around the
node the plant is about to spawn on for it to happen. Defaults to
0.
facedir: The value passed to the param2 variable when adding the plant node
to the map. Defaults to 0 if left out or set to nil.
-----
The second function, grow_plants() is defined like so:
@ -89,6 +92,9 @@ grow_nodes: This node must be under the plant in order for it to grow at
{"default:dirt_with_grass","default:sand"}. This is so that
the plant can be manually placed on something like a flower
pot or something without it growing and eventually dieing.
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.
-----
plant_valid_wall() expects only a single parameter, "pos", which is a table

View File

@ -90,7 +90,7 @@ end
-- The spawning ABM
spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid, seed_diff, lightmin, lightmax, nneighbors, ocount)
spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid, seed_diff, lightmin, lightmax, nneighbors, ocount, facedir)
if seed_diff == nil then seed_diff = 0 end
if lightmin == nil then lightmin = 0 end
if lightmax == nil then lightmax = LIGHT_MAX end
@ -120,7 +120,7 @@ spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid,
minetest.env:add_node(p_top, { name = "poisonivy:climbing", param2 = walldir })
else
dbg("Spawn: "..splant.." at "..dump(p_top).." on "..ssurface)
minetest.env:add_node(p_top, { name = splant })
minetest.env:add_node(p_top, { name = splant, param2 = facedir })
end
end
end
@ -130,7 +130,7 @@ end
-- The growing ABM
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)
minetest.register_abm({
nodenames = { gplant },
interval = gdelay,
@ -161,7 +161,11 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
elseif gresult ~= nil then
dbg("Grow: "..gplant.." -> "..gresult.." at ("..dump(pos)..")")
if facedir == nil then
minetest.env:add_node(pos, { name = gresult })
else
minetest.env:add_node(pos, { name = gresult, param2 = facedir })
end
else
dbg("Die: "..gplant.." at ("..dump(pos)..")")
minetest.env:remove_node(pos)
@ -288,9 +292,9 @@ if enable_flowers then
})
spawn_on_surfaces(spawn_delay/2, "flowers:flower_waterlily", 15 , spawn_chance*3, "default:water_source" , {"group:flower"}, flowers_seed_diff, 10)
spawn_on_surfaces(spawn_delay*2, "flowers:flower_seaweed" , 0.1, spawn_chance*2, "default:water_source" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:dirt_with_grass"}, 0)
spawn_on_surfaces(spawn_delay*2, "flowers:flower_seaweed" , 0.1, spawn_chance*2, "default:dirt_with_grass", {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 1)
spawn_on_surfaces(spawn_delay*2, "flowers:flower_seaweed" , 0.1, spawn_chance*2, "default:stone" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 6)
spawn_on_surfaces(spawn_delay*2, "flowers:flower_seaweed" , 0.1, spawn_chance*2, "default:water_source" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:dirt_with_grass"}, 0, 1)
spawn_on_surfaces(spawn_delay*2, "flowers:flower_seaweed" , 0.1, spawn_chance*2, "default:dirt_with_grass", {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 1, 1)
spawn_on_surfaces(spawn_delay*2, "flowers:flower_seaweed" , 0.1, spawn_chance*2, "default:stone" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 6, 1)
minetest.register_craftitem(":flowers:flower_pot", {

View File

@ -90,7 +90,8 @@ end
-- The spawning ABM
spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid, seed_diff, lightmin, lightmax, nneighbors, ocount)
spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid, seed_diff, lightmin, lightmax, nneighbors, ocount, facedir)
if seed_diff == nil then seed_diff = 0 end
if lightmin == nil then lightmin = 0 end
if lightmax == nil then lightmax = LIGHT_MAX end
if nneighbors == nil then nneighbors = ssurface end
@ -119,7 +120,7 @@ spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid,
minetest.env:add_node(p_top, { name = "poisonivy:climbing", param2 = walldir })
else
dbg("Spawn: "..splant.." at "..dump(p_top).." on "..ssurface)
minetest.env:add_node(p_top, { name = splant })
minetest.env:add_node(p_top, { name = splant, param2 = facedir })
end
end
end
@ -129,7 +130,7 @@ end
-- The growing ABM
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)
minetest.register_abm({
nodenames = { gplant },
interval = gdelay,
@ -160,7 +161,7 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
elseif gresult ~= nil then
dbg("Grow: "..gplant.." -> "..gresult.." at ("..dump(pos)..")")
minetest.env:add_node(pos, { name = gresult })
minetest.env:add_node(pos, { name = gresult, param2 = facedir })
else
dbg("Die: "..gplant.." at ("..dump(pos)..")")
minetest.env:remove_node(pos)