Merge pull request #1 from tenplus1/patch-1

replace plant abm with on_generated
This commit is contained in:
D00Med 2016-10-20 19:31:43 +10:00 committed by GitHub
commit 6620b5415b
1 changed files with 24 additions and 27 deletions

View File

@ -862,31 +862,28 @@ minetest.register_decoration({
}) })
end end
--ABM spawning -- Spawn underground plants in newly generated areas
-- ABM from the Mushroom mod
--by DanDuncombe and VanessaE
-- License of code ; WTFPL
-- Natural Spawning ABM local frequency = 200
minetest.register_abm({
nodenames = { minetest.register_on_generated(function(minp, maxp)
"default:stone", if maxp.y > 0 then
}, return
neighbors = {"air"}, end
interval = 500, local stone = minetest.find_nodes_in_area_under_air(minp, maxp,
chance = 200, {"default:stone", "default:desert_stone"})
action = function(pos, node) for n = 1, #stone do
local top_pos = {x=pos.x, y=pos.y+1, z=pos.z} if math.random(1, frequency) == 1 then
if minetest.get_node(top_pos).name == "air" then local pos = {x = stone[n].x, y = stone[n].y + 1, z = stone[n].z }
if minetest.find_node_near(pos, 3, {"default:lava_source"}) then if minetest.find_node_near(pos, 3, {"group:lava"}) then
minetest.add_node(top_pos, {name="moreplants:firefung"}) minetest.add_node(pos, {name = "moreplants:firefung"})
elseif minetest.get_node_light(top_pos, nil) < 8 then elseif minetest.get_node_light(pos, nil) < 8 then
if minetest.find_node_near(pos, 3, {"default:water_source"}) then if minetest.find_node_near(pos, 3, {"group:water"}) then
minetest.add_node(top_pos, {name="moreplants:bluemush"}) minetest.add_node(pos, {name = "moreplants:bluemush"})
else else
minetest.add_node(top_pos, {name="moreplants:caveflower"}) minetest.add_node(pos, {name = "moreplants:caveflower"})
end end
end end
end end
end end
}) end)