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

one of the previous changes screwed up spawning jungle grass while trying to

fix the waterlily bug.  Reverted it.

This should, however, finally fix jungle grass turning into dry shrubs when it
shouldn't, and the list of growing surfaces seems to work properly now.  Will
fix the waterlily bug later.
This commit is contained in:
Vanessa Ezekowitz 2012-12-02 17:51:17 -05:00
parent e3a9d05871
commit 46ae097460
3 changed files with 44 additions and 42 deletions

View File

@ -65,7 +65,7 @@ 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 node the plant is about to spawn on for it to happen. Defaults to
0. 0.
facedir: The value passed to the param2 variable when adding the plant node 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. to the map. Defaults to 0.
----- -----
The second function, grow_plants() is defined like so: The second function, grow_plants() is defined like so:

View File

@ -25,7 +25,7 @@ local perlin_octaves = 3
local perlin_persistence = 0.2 local perlin_persistence = 0.2
local perlin_scale = 25 local perlin_scale = 25
local plantlife_limit = 0.6 -- compared against perlin noise. lower = more abundant local plantlife_limit = 0.5 -- compared against perlin noise. lower = more abundant
local spawn_delay = 2000 -- 2000 local spawn_delay = 2000 -- 2000
local spawn_chance = 100 -- 100 local spawn_chance = 100 -- 100
@ -112,7 +112,7 @@ spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid,
if (minetest.env:find_node_near(p_top, sradius, savoid) == nil ) if (minetest.env:find_node_near(p_top, sradius, savoid) == nil )
and (n_light >= lightmin) and (n_light >= lightmin)
and (n_light <= lightmax) and (n_light <= lightmax)
and table.getn(minetest.env:find_nodes_in_area({x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y, z=pos.z+1}, nneighbors)) > ocount and table.getn(minetest.env:find_nodes_in_area({x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y, z=pos.z+1}, nneighbors)) > ocount
then then
local walldir = plant_valid_wall(p_top) local walldir = plant_valid_wall(p_top)
if splant == "poisonivy:seedling" and walldir ~= nil then if splant == "poisonivy:seedling" and walldir ~= nil then
@ -141,15 +141,7 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
local n_top = minetest.env:get_node(p_top) local n_top = minetest.env:get_node(p_top)
local n_bot = minetest.env:get_node(p_bot) local n_bot = minetest.env:get_node(p_bot)
if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air" if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air" then
and (n_bot.name == "default:dirt_with_grass"
or n_bot.name == "default:sand"
or n_bot.name == "default:desert_sand")
then
-- corner case for changing short junglegrass to dry shrub in desert
if (n_bot.name == dry_early_node) and (gplant == "junglegrass:short") then
gresult = "default:dry_shrub"
end
-- corner case for wall-climbing poison ivy -- corner case for wall-climbing poison ivy
if gplant == "poisonivy:climbing" then if gplant == "poisonivy:climbing" then
@ -159,16 +151,22 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
minetest.env:add_node(p_top, { name = gplant, param2 = walldir }) minetest.env:add_node(p_top, { name = gplant, param2 = walldir })
end end
-- corner case for changing short junglegrass to dry shrub in desert
elseif n_bot.name == dry_early_node and gplant == "junglegrass:short" then
dbg("Die: "..gplant.." becomes default:dry_shrub at ("..dump(pos)..")")
minetest.env:add_node(pos, { name = "default:dry_shrub" })
elseif gresult == nil then
dbg("Die: "..gplant.." at ("..dump(pos)..")")
minetest.env:remove_node(pos)
elseif gresult ~= nil then elseif gresult ~= nil then
dbg("Grow: "..gplant.." -> "..gresult.." at ("..dump(pos)..")") dbg("Grow: "..gplant.." becomes "..gresult.." at ("..dump(pos)..")")
if facedir == nil then if facedir == nil then
minetest.env:add_node(pos, { name = gresult }) minetest.env:add_node(pos, { name = gresult })
else else
minetest.env:add_node(pos, { name = gresult, param2 = facedir }) minetest.env:add_node(pos, { name = gresult, param2 = facedir })
end end
else
dbg("Die: "..gplant.." at ("..dump(pos)..")")
minetest.env:remove_node(pos)
end end
end end
end end
@ -291,10 +289,11 @@ 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_waterlily", 10 , spawn_chance*3, "default:water_source" , {"group:flower"}, flowers_seed_diff, 10, nil, {"default:dirt_with_grass"}, nil, nil,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, 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: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:stone" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 6, 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", { minetest.register_craftitem(":flowers:flower_pot", {
@ -385,10 +384,10 @@ if enable_junglegrass then
}, },
}) })
spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance/50, "default:dirt_with_grass", {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5) spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance, "default:dirt_with_grass", {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5)
spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance/50, "default:sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5) spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance*2, "default:sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5)
spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance/10, "default:desert_sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5) spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance*3, "default:desert_sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5)
spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance/10, "default:desert_sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5) spawn_on_surfaces(spawn_delay*2, "junglegrass:shortest", 4, spawn_chance*3, "default:desert_sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5)
for i in ipairs(grasses_list) do for i in ipairs(grasses_list) do
grow_plants(grow_delay, grow_chance/2, grasses_list[i][1], grasses_list[i][2], "default:desert_sand", {"default:dirt_with_grass", "default:sand", "default:desert_sand"}) grow_plants(grow_delay, grow_chance/2, grasses_list[i][1], grasses_list[i][2], "default:desert_sand", {"default:dirt_with_grass", "default:sand", "default:desert_sand"})

View File

@ -112,7 +112,7 @@ spawn_on_surfaces = function(sdelay, splant, sradius, schance, ssurface, savoid,
if (minetest.env:find_node_near(p_top, sradius, savoid) == nil ) if (minetest.env:find_node_near(p_top, sradius, savoid) == nil )
and (n_light >= lightmin) and (n_light >= lightmin)
and (n_light <= lightmax) and (n_light <= lightmax)
and table.getn(minetest.env:find_nodes_in_area({x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y, z=pos.z+1}, nneighbors)) > ocount and table.getn(minetest.env:find_nodes_in_area({x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y, z=pos.z+1}, nneighbors)) > ocount
then then
local walldir = plant_valid_wall(p_top) local walldir = plant_valid_wall(p_top)
if splant == "poisonivy:seedling" and walldir ~= nil then if splant == "poisonivy:seedling" and walldir ~= nil then
@ -141,15 +141,7 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
local n_top = minetest.env:get_node(p_top) local n_top = minetest.env:get_node(p_top)
local n_bot = minetest.env:get_node(p_bot) local n_bot = minetest.env:get_node(p_bot)
if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air" if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air" then
and (n_bot.name == "default:dirt_with_grass"
or n_bot.name == "default:sand"
or n_bot.name == "default:desert_sand")
then
-- corner case for changing short junglegrass to dry shrub in desert
if (n_bot.name == dry_early_node) and (gplant == "junglegrass:short") then
gresult = "default:dry_shrub"
end
-- corner case for wall-climbing poison ivy -- corner case for wall-climbing poison ivy
if gplant == "poisonivy:climbing" then if gplant == "poisonivy:climbing" then
@ -159,12 +151,22 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_no
minetest.env:add_node(p_top, { name = gplant, param2 = walldir }) minetest.env:add_node(p_top, { name = gplant, param2 = walldir })
end end
elseif gresult ~= nil then -- corner case for changing short junglegrass to dry shrub in desert
dbg("Grow: "..gplant.." -> "..gresult.." at ("..dump(pos)..")") elseif n_bot.name == dry_early_node and gplant == "junglegrass:short" then
minetest.env:add_node(pos, { name = gresult, param2 = facedir }) dbg("Die: "..gplant.." becomes default:dry_shrub at ("..dump(pos)..")")
else minetest.env:add_node(pos, { name = "default:dry_shrub" })
elseif gresult == nil then
dbg("Die: "..gplant.." at ("..dump(pos)..")") dbg("Die: "..gplant.." at ("..dump(pos)..")")
minetest.env:remove_node(pos) minetest.env:remove_node(pos)
elseif gresult ~= nil then
dbg("Grow: "..gplant.." becomes "..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
end end
end end
end end
@ -287,10 +289,11 @@ 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_waterlily", 10 , spawn_chance*3, "default:water_source" , {"group:flower"}, flowers_seed_diff, 10, nil, {"default:dirt_with_grass"}, nil, nil,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: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: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: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", { minetest.register_craftitem(":flowers:flower_pot", {