Made growing plants require the same surfaces under them as are needed to

spawn, so plants places on e.g. cobble or a flower poit don't change.
This commit is contained in:
Vanessa Ezekowitz 2012-11-30 00:46:27 -05:00
parent 91b196a72f
commit 6b8bb9ff61
3 changed files with 21 additions and 81 deletions

60
README~
View File

@ -1,60 +0,0 @@
--- README for Flowers:
This is a mostly-rewrite of Ironzorg's flowers mod, using more recent features
in the game, to make the code perform better.
Dependencies: none (just the game's default stuff)
License: cc-by-sa 3.0 for the textures, WTFPL for everything else.
--- README for Jungle Grass:
Since recent versions of Minetest no longer contain jungle biomes, and
hence no jungle grass, I created this mod to re-add said grass back into
the game, with a twist: There are now four different sizes of grasses,
all of which yield a single junglegrass object when gathered (so all
four sizes may be used where jungle grass is called for). The largest
size uses the game's standard jungle grass node, while the others are
defined by this mod.
Junglegrass will spawn on dirt, grass, sand, desert sand and the tops of
papyrus and cactus (though rarely), and will do so anywhere in the map.
Grass on the ground will grow and eventually die (or turn into dry
shrubs, in the desert), given enough time.
Adjusting the overall spawn/growth rate is easily done by tweaking the
MAX_RATIO variable at the top of init.lua. A larger value results in
less frequent events.
Dependencies: none (just the game's default stuff)
License: cc-by-sa 3.0 for the textures, WTFPL for everything else.
--- README for Poison Ivy:
This is a mod for minetest and its forks to add poison ivy.
Ivy will spawn on dirt or grass, and in some cases, on vertical
surfaces, trees, and jungle trees where they meet the dirt or grass.
Ivy previously spawned will occasionally grow taller/thicker or start
climbing up said vertical surfaces and trees.
At present, the plants present little more than an annoyance - they can
only be cut down and either re-planted or thrown away. No damage is
done by harvesting them, yet. ;-)
Mod based on ironzorg's flowers mod; I left the spawn rates the same so
the plants don't take over your world (in fact, they may take a few
day/night cycles before you start to notice them). If you want a really
overgrown environment just lower the MAX_RATIO and GROWING_DELAY
variables at the top of init.lua.
Textures hand-drawn by me (16x16px).
License: WTFPL (applies to all parts)
Depends: None.
No crafting recipes (didn't see a point :-) ).

View File

@ -129,7 +129,7 @@ end
-- The growing ABM
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, dont_grow_nodes)
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_nodes)
minetest.register_abm({
nodenames = { gplant },
interval = gdelay,
@ -140,18 +140,18 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, dont_gr
local n_top = minetest.env:get_node(p_top)
local n_bot = minetest.env:get_node(p_bot)
dbg("abm triggered for "..gplant.." on "..n_bot.name.." at "..dump(pos).." -- checking if its in "..dump(dont_grow_nodes))
if string.find(dump(dont_grow_nodes), n_bot.name) == nil and n_top.name == "air" then
dbg("It wasn't, and it has air above it.")
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"
dbg("Want to change "..gplant.." to "..gresult)
end
-- corner case for wall-climbing poison ivy
if gplant == "poisonivy:climbing" then
dbg("Want to grow "..gplant)
local walldir=plant_valid_wall(p_top)
if walldir ~= nil then
dbg("Grow: "..gplant.." upwards to ("..dump(p_top)..")")
@ -247,7 +247,7 @@ if enable_flowers then
}
})
spawn_on_surfaces(delay, "flowers:flower_"..flower, radius, chance, "default:dirt_with_grass", {"group:flower"}, flowers_seed_diff)
spawn_on_surfaces(delay, "flowers:flower_"..flower, radius, chance, "default:dirt_with_grass", {"group:flower", "group:poisonivy"}, flowers_seed_diff)
end
minetest.register_node(":flowers:flower_waterlily", {
@ -386,7 +386,7 @@ if enable_junglegrass then
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)
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:cactus", "default:papyrus"})
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"})
end
end
@ -441,8 +441,8 @@ if enable_poisonivy then
})
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")
grow_plants(spawn_delay, grow_chance*2, "poisonivy:climbing")
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)
end
print(loadstr..")")

View File

@ -18,7 +18,7 @@ local enable_flowers = true
local enable_junglegrass = true
local enable_poisonivy = true
local plantlife_debug = true
local plantlife_debug = false
local plantlife_seed_diff = 123
local perlin_octaves = 3
@ -129,7 +129,7 @@ end
-- The growing ABM
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, dont_grow_nodes)
grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, grow_nodes)
minetest.register_abm({
nodenames = { gplant },
interval = gdelay,
@ -140,18 +140,18 @@ grow_plants = function(gdelay, gchance, gplant, gresult, dry_early_node, dont_gr
local n_top = minetest.env:get_node(p_top)
local n_bot = minetest.env:get_node(p_bot)
dbg("abm triggered for "..gplant.." on "..n_bot.name.." at "..dump(pos).." -- checking if its in "..dump(dont_grow_nodes))
if string.find(dump(dont_grow_nodes), n_bot.name) == nil and n_top.name == "air" then
dbg("It wasn't, and it has air above it.")
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"
dbg("Want to change "..gplant.." to "..gresult)
end
-- corner case for wall-climbing poison ivy
if gplant == "poisonivy:climbing" then
dbg("Want to grow "..gplant)
local walldir=plant_valid_wall(p_top)
if walldir ~= nil then
dbg("Grow: "..gplant.." upwards to ("..dump(p_top)..")")
@ -247,7 +247,7 @@ if enable_flowers then
}
})
spawn_on_surfaces(delay, "flowers:flower_"..flower, radius, chance, "default:dirt_with_grass", {"group:flower"}, flowers_seed_diff)
spawn_on_surfaces(delay, "flowers:flower_"..flower, radius, chance, "default:dirt_with_grass", {"group:flower", "group:poisonivy"}, flowers_seed_diff)
end
minetest.register_node(":flowers:flower_waterlily", {
@ -386,7 +386,7 @@ if enable_junglegrass then
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)
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:cactus", "default:papyrus"})
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"})
end
end
@ -441,8 +441,8 @@ if enable_poisonivy then
})
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")
grow_plants(spawn_delay, grow_chance*2, "poisonivy:climbing")
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)
end
print(loadstr..")")