ethereal/flowers.lua

97 lines
2.0 KiB
Lua
Raw Normal View History

2014-11-09 19:17:41 +00:00
-- Flowers spread over all types of soil
minetest.register_abm({
nodenames = {"group:flora"},
neighbors = {"group:soil"},
interval = 13, --25,
chance = 96, --15,
2015-11-07 20:50:50 +00:00
catch_up = false,
2014-11-09 19:17:41 +00:00
action = function(pos, node)
2014-11-21 20:26:04 +00:00
2014-11-09 19:17:41 +00:00
local light = minetest.get_node_light(pos)
2014-11-21 20:26:04 +00:00
2015-11-28 13:22:39 +00:00
if not light
or light < 13 then
2014-11-09 19:17:41 +00:00
return
end
2014-11-21 20:26:04 +00:00
2015-07-04 12:22:39 +01: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}
2015-11-28 13:22:39 +00:00
local num = #minetest.find_nodes_in_area_under_air(
pos0, pos1, "group:flora")
2014-11-21 20:26:04 +00:00
2015-11-28 13:22:39 +00:00
if num > 3
and node.name == "ethereal:crystalgrass" then
2014-12-29 11:03:11 +00:00
2015-11-28 13:22:39 +00:00
local grass = minetest.find_nodes_in_area_under_air(
pos0, pos1, {"ethereal:crystalgrass"})
local crystal = minetest.find_nodes_in_area_under_air(
pos0, pos1, {"ethereal:crystal_spike"})
if #grass > 4
and #crystal < 1 then
grass = grass[math.random(#grass)]
2015-11-28 13:22:39 +00:00
grass.y = grass.y - 1
2015-11-28 13:22:39 +00:00
if minetest.get_node(grass).name == "ethereal:crystal_dirt" then
2015-11-28 13:22:39 +00:00
grass.y = grass.y + 1
2015-11-28 13:22:39 +00:00
2016-01-09 12:25:33 +00:00
minetest.swap_node(grass, {name = "ethereal:crystal_spike"})
2014-12-29 11:03:11 +00:00
end
end
2014-11-09 19:17:41 +00:00
return
2015-11-28 13:22:39 +00:00
2015-12-13 10:30:17 +00:00
elseif num > 3
and node.name == "ethereal:dry_shrub" then
local grass = minetest.find_nodes_in_area_under_air(
pos0, pos1, {"ethereal:dry_shrub"})
local fflower = minetest.find_nodes_in_area_under_air(
pos0, pos1, {"ethereal:fire_flower"})
if #grass > 8
2015-12-13 10:30:17 +00:00
and #fflower < 1 then
grass = grass[math.random(#grass)]
grass.y = grass.y - 1
if minetest.get_node(grass).name == "ethereal:fiery_dirt" then
grass.y = grass.y + 1
2016-01-09 12:25:33 +00:00
minetest.swap_node(grass, {name = "ethereal:fire_flower"})
2015-12-13 10:30:17 +00:00
end
end
return
2015-11-28 13:22:39 +00:00
elseif num > 3 then
return
2014-11-09 19:17:41 +00:00
end
2014-11-21 20:26:04 +00:00
2015-11-28 13:22:39 +00:00
local seedling = minetest.find_nodes_in_area_under_air(
pos0, pos1, {"group:soil"})
2014-11-21 20:26:04 +00:00
2014-11-09 19:17:41 +00:00
if #seedling > 0 then
2015-11-28 13:22:39 +00:00
2014-11-09 19:17:41 +00:00
seedling = seedling[math.random(#seedling)]
seedling.y = seedling.y + 1
2015-11-28 13:22:39 +00:00
2014-11-09 19:17:41 +00:00
light = minetest.get_node_light(seedling)
2015-11-28 13:22:39 +00:00
if not light
or light < 13 then
2014-11-09 19:17:41 +00:00
return
end
2015-11-28 13:22:39 +00:00
minetest.swap_node(seedling, {name = node.name})
2014-11-09 19:17:41 +00:00
end
end,
})