Skip to content

Commit

Permalink
flowers: Light check optimisation in mushroom spread
Browse files Browse the repository at this point in the history
  • Loading branch information
HybridDog authored and paramat committed Mar 31, 2019
1 parent 88d7988 commit b207250
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mods/flowers/init.lua
Expand Up @@ -221,8 +221,10 @@ minetest.register_node("flowers:mushroom_brown", {
-- Mushroom spread and death

function flowers.mushroom_spread(pos, node)
if minetest.get_node_light(pos, nil) == 15 then
minetest.remove_node(pos)
if minetest.get_node_light(pos, 0.5) > 3 then
if minetest.get_node_light(pos, nil) == 15 then
minetest.remove_node(pos)
end
return
end
local positions = minetest.find_nodes_in_area_under_air(
Expand All @@ -234,8 +236,7 @@ function flowers.mushroom_spread(pos, node)
end
local pos2 = positions[math.random(#positions)]
pos2.y = pos2.y + 1
if minetest.get_node_light(pos, 0.5) <= 3 and
minetest.get_node_light(pos2, 0.5) <= 3 then
if minetest.get_node_light(pos2, 0.5) <= 3 then
minetest.set_node(pos2, {name = node.name})
end
end
Expand Down

0 comments on commit b207250

Please sign in to comment.