2014-11-09 22:17:41 +03:00
|
|
|
-- Flowers spread over all types of soil
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:flora"},
|
|
|
|
neighbors = {"group:soil"},
|
2015-02-04 13:26:48 +03:00
|
|
|
interval = 50,
|
|
|
|
chance = 25,
|
2014-11-09 22:17:41 +03:00
|
|
|
action = function(pos, node)
|
2014-11-21 23:26:04 +03:00
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
local light = minetest.get_node_light(pos)
|
2014-11-21 23:26:04 +03:00
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
if not light or light < 13 then
|
|
|
|
return
|
|
|
|
end
|
2014-11-21 23:26:04 +03:00
|
|
|
|
2015-07-04 14:22:39 +03:00
|
|
|
local pos0 = {x = pos.x - 4, y = pos.y - 2, z = pos.z - 4}
|
|
|
|
local pos1 = {x = pos.x + 4, y = pos.y + 2, z = pos.z + 4}
|
2014-11-21 23:26:04 +03:00
|
|
|
|
|
|
|
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 then
|
2014-12-29 14:03:11 +03:00
|
|
|
|
2015-02-04 13:26:48 +03:00
|
|
|
local grass = minetest.find_nodes_in_area(pos0, pos1, {"ethereal:crystalgrass"})
|
|
|
|
local crystal = minetest.find_nodes_in_area(pos0, pos1, {"ethereal:crystal_spike"})
|
|
|
|
|
|
|
|
if #grass > 6 and #crystal < 1 then
|
|
|
|
grass = grass[math.random(#grass)]
|
|
|
|
grass.y = grass.y - 1
|
|
|
|
if minetest.get_node(grass).name == "ethereal:crystal_dirt" then
|
|
|
|
grass.y = grass.y + 1
|
2015-07-04 14:22:39 +03:00
|
|
|
minetest.set_node(grass, {name = "ethereal:crystal_spike"})
|
2014-12-29 14:03:11 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
return
|
|
|
|
end
|
2014-11-21 23:26:04 +03:00
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
local seedling = minetest.find_nodes_in_area(pos0, pos1, {"group:soil"})
|
2014-11-21 23:26:04 +03:00
|
|
|
|
2014-11-09 22:17:41 +03:00
|
|
|
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
|
|
|
|
if minetest.get_node(seedling).name == "air" then
|
2015-07-04 14:22:39 +03:00
|
|
|
minetest.set_node(seedling, {name = node.name})
|
2014-11-09 22:17:41 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
2015-07-04 14:22:39 +03:00
|
|
|
})
|