Flora spread: Allow spread on rainforest litter. Other improvements

Use the soil group more instead of checking for multiple node names.
Remove 'neighbors' from ABM.
Turn any flora to dry shrub if on a non-soil, except when on default:sand
to avoid dune grasses being replaced.
Search for "group:soil" when searching for a position for the new flora
node, instead of searching for multiple node names, however do not spread
flora onto desert sand, which is in the soil group.

Remove default:dirt_with_snow from the soil group as it would be frozen
soil. It can be dug and placed to turn it into dirt (consider this some
extra work needed to make it cultivatable).
This commit is contained in:
paramat 2017-03-18 17:54:03 +00:00
parent 2a74032745
commit 86fd616f3c
2 changed files with 16 additions and 15 deletions

View File

@ -434,7 +434,7 @@ minetest.register_node("default:dirt_with_snow", {
tiles = {"default_snow.png", "default_dirt.png", tiles = {"default_snow.png", "default_dirt.png",
{name = "default_dirt.png^default_snow_side.png", {name = "default_dirt.png^default_snow_side.png",
tileable_vertical = false}}, tileable_vertical = false}},
groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1, snowy = 1}, groups = {crumbly = 3, spreading_dirt_type = 1, snowy = 1},
drop = 'default:dirt', drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({ sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.15}, footstep = {name = "default_snow_footstep", gain = 0.15},

View File

@ -107,12 +107,11 @@ function flowers.flower_spread(pos, node)
pos.y = pos.y - 1 pos.y = pos.y - 1
local under = minetest.get_node(pos) local under = minetest.get_node(pos)
pos.y = pos.y + 1 pos.y = pos.y + 1
if under.name == "default:desert_sand" then if minetest.get_item_group(under.name, "soil") == 0 and
-- Do not replace sand dune grasses
under.name ~= "default:sand" then
minetest.set_node(pos, {name = "default:dry_shrub"}) minetest.set_node(pos, {name = "default:dry_shrub"})
return return
elseif under.name ~= "default:dirt_with_grass" and
under.name ~= "default:dirt_with_dry_grass" then
return
end end
local light = minetest.get_node_light(pos) local light = minetest.get_node_light(pos)
@ -126,24 +125,26 @@ function flowers.flower_spread(pos, node)
return return
end end
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1, local soils = minetest.find_nodes_in_area_under_air(
{"default:dirt_with_grass", "default:dirt_with_dry_grass"}) pos0, pos1, "group:soil")
if #seedling > 0 then if #soils > 0 then
seedling = seedling[math.random(#seedling)] local seedling = soils[math.random(#soils)]
seedling.y = seedling.y + 1 local seedling_above =
light = minetest.get_node_light(seedling) {x = seedling.x, y = seedling.y + 1, z = seedling.z}
if not light or light < 13 then light = minetest.get_node_light(seedling_above)
if not light or light < 13 or
-- Desert sand is in the soil group
minetest.get_node(seedling).name == "default:desert_sand" then
return return
end end
minetest.set_node(seedling, {name = node.name})
minetest.set_node(seedling_above, {name = node.name})
end end
end end
minetest.register_abm({ minetest.register_abm({
label = "Flower spread", label = "Flower spread",
nodenames = {"group:flora"}, nodenames = {"group:flora"},
neighbors = {"default:dirt_with_grass", "default:dirt_with_dry_grass",
"default:desert_sand"},
interval = 13, interval = 13,
chance = 96, chance = 96,
action = function(...) action = function(...)