Flowers: Make flower spread a public function to enable override
Remove search for 'group:flora_block' Enable flora spread on 'dirt with dry grass'
This commit is contained in:
parent
80664f9f8a
commit
ab7b7c7504
@ -71,45 +71,52 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- Flower spread
|
-- Flower spread
|
||||||
|
-- Public function to enable override by mods
|
||||||
|
|
||||||
minetest.register_abm({
|
function flowers.flower_spread(pos, node)
|
||||||
nodenames = {"group:flora"},
|
pos.y = pos.y - 1
|
||||||
neighbors = {"default:dirt_with_grass", "default:desert_sand"},
|
local under = minetest.get_node(pos)
|
||||||
interval = 13,
|
pos.y = pos.y + 1
|
||||||
chance = 96,
|
if under.name == "default:desert_sand" then
|
||||||
action = function(pos, node)
|
minetest.set_node(pos, {name = "default:dry_shrub"})
|
||||||
pos.y = pos.y - 1
|
return
|
||||||
local under = minetest.get_node(pos)
|
elseif under.name ~= "default:dirt_with_grass" and
|
||||||
pos.y = pos.y + 1
|
under.name ~= "default:dirt_with_dry_grass" then
|
||||||
if under.name == "default:desert_sand" then
|
return
|
||||||
minetest.set_node(pos, {name = "default:dry_shrub"})
|
end
|
||||||
return
|
|
||||||
elseif under.name ~= "default:dirt_with_grass" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local light = minetest.get_node_light(pos)
|
local light = minetest.get_node_light(pos)
|
||||||
|
if not light or light < 13 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local pos0 = vector.subtract(pos, 4)
|
||||||
|
local pos1 = vector.add(pos, 4)
|
||||||
|
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1,
|
||||||
|
{"default:dirt_with_grass", "default:dirt_with_dry_grass"})
|
||||||
|
if #seedling > 0 then
|
||||||
|
seedling = seedling[math.random(#seedling)]
|
||||||
|
seedling.y = seedling.y + 1
|
||||||
|
light = minetest.get_node_light(seedling)
|
||||||
if not light or light < 13 then
|
if not light or light < 13 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
minetest.set_node(seedling, {name = node.name})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local pos0 = vector.subtract(pos, 4)
|
minetest.register_abm({
|
||||||
local pos1 = vector.add(pos, 4)
|
nodenames = {"group:flora"},
|
||||||
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 or
|
neighbors = {"default:dirt_with_grass", "default:dirt_with_dry_grass",
|
||||||
#minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
|
"default:desert_sand"},
|
||||||
return
|
interval = 13,
|
||||||
end
|
chance = 96,
|
||||||
|
action = function(...)
|
||||||
local seedling = minetest.find_nodes_in_area_under_air(pos0, pos1, "default:dirt_with_grass")
|
flowers.flower_spread(...)
|
||||||
if #seedling > 0 then
|
|
||||||
seedling = seedling[math.random(#seedling)]
|
|
||||||
seedling.y = seedling.y + 1
|
|
||||||
light = minetest.get_node_light(seedling)
|
|
||||||
if not light or light < 13 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.set_node(seedling, {name = node.name})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -156,7 +163,9 @@ minetest.register_node("flowers:mushroom_brown", {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- mushroom spread and death
|
|
||||||
|
-- Mushroom spread and death
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
|
nodenames = {"flowers:mushroom_brown", "flowers:mushroom_red"},
|
||||||
interval = 11,
|
interval = 11,
|
||||||
@ -190,7 +199,9 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- these old mushroom related nodes can be simplified now
|
|
||||||
|
-- These old mushroom related nodes can be simplified now
|
||||||
|
|
||||||
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
|
minetest.register_alias("flowers:mushroom_spores_brown", "flowers:mushroom_brown")
|
||||||
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
|
minetest.register_alias("flowers:mushroom_spores_red", "flowers:mushroom_red")
|
||||||
minetest.register_alias("flowers:mushroom_fertile_brown", "flowers:mushroom_brown")
|
minetest.register_alias("flowers:mushroom_fertile_brown", "flowers:mushroom_brown")
|
||||||
|
Loading…
Reference in New Issue
Block a user