diff options
author | tenplus1 <kinsellaja@yahoo.com> | 2014-11-09 19:17:41 +0000 |
---|---|---|
committer | tenplus1 <kinsellaja@yahoo.com> | 2014-11-09 19:17:41 +0000 |
commit | c4d4e229f7d63959508e4505099a7fca5ca87534 (patch) | |
tree | 55e1164fae6d4876bc7ef5468186384f21ee12f6 /flowers.lua |
First Commit by TenPlus1
Diffstat (limited to 'flowers.lua')
-rw-r--r-- | flowers.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/flowers.lua b/flowers.lua new file mode 100644 index 0000000..39ba76a --- /dev/null +++ b/flowers.lua @@ -0,0 +1,34 @@ +-- Flowers spread over all types of soil +minetest.register_abm({ + nodenames = {"group:flora"}, + neighbors = {"group:soil"}, + 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 + 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 + light = minetest.get_node_light(seedling) + if not light or light < 13 then + return + end + if minetest.get_node(seedling).name == "air" then + minetest.set_node(seedling, {name=node.name}) + end + end + end, +}) |