summaryrefslogtreecommitdiff
path: root/flowers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'flowers.lua')
-rw-r--r--flowers.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/flowers.lua b/flowers.lua
index 39ba76a..94f20bd 100644
--- a/flowers.lua
+++ b/flowers.lua
@@ -5,20 +5,22 @@ minetest.register_abm({
interval = 40,
chance = 20,
action = function(pos, node)
+
local light = minetest.get_node_light(pos)
+
if not light or light < 13 then
return
end
-
- local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
- local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
-
- local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
- if #flowers > 3 then
+
+ 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}
+
+ if #minetest.find_nodes_in_area(pos0, pos1, "group:flora") > 3 then
return
end
-
+
local seedling = minetest.find_nodes_in_area(pos0, pos1, {"group:soil"})
+
if #seedling > 0 then
seedling = seedling[math.random(#seedling)]
seedling.y = seedling.y + 1