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
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.
to the map. Defaults to 0.
-----
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_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_chance = 100 -- 100
@ -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_bot = minetest.env:get_node(p_bot)
if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air"
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
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
@ -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 })
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
dbg("Grow: "..gplant.." -> "..gresult.." at ("..dump(pos)..")")
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
else
dbg("Die: "..gplant.." at ("..dump(pos)..")")
minetest.env:remove_node(pos)
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_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)
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:stone" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 6, 1)
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/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/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/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, "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*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*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*3, "default:desert_sand" , {"group:junglegrass", "default:junglegrass", "default:dry_shrub"}, junglegrass_seed_diff, 5)
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"})

View File

@ -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_bot = minetest.env:get_node(p_bot)
if string.find(dump(grow_nodes), n_bot.name) ~= nil and n_top.name == "air"
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
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
@ -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 })
end
elseif gresult ~= nil then
dbg("Grow: "..gplant.." -> "..gresult.." at ("..dump(pos)..")")
minetest.env:add_node(pos, { name = gresult, param2 = facedir })
else
-- 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
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
@ -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_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_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:stone" , {"group:flower"}, flowers_seed_diff, 4, 10, {"default:water_source"} , 6, 1)
minetest.register_craftitem(":flowers:flower_pot", {