Skip to content

Commit

Permalink
Fire: Optimize spreading ABM.
Browse files Browse the repository at this point in the history
No need to find_node_near twice with the same params.
  • Loading branch information
sofar authored and paramat committed Mar 15, 2016
1 parent 28884cc commit e5304ce
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions mods/fire/init.lua
Expand Up @@ -254,22 +254,20 @@ else
catch_up = false,
action = function(p0, node, _, _)
-- If there are no flammable nodes around flame, remove flame
if not minetest.find_node_near(p0, 1, {"group:flammable"}) then
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
if not p then
minetest.remove_node(p0)
return
end
if math.random(1, 4) == 1 then
-- remove flammable nodes around flame
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
if p then
local node = minetest.get_node(p)
local def = minetest.registered_nodes[node.name]
if def.on_burn then
def.on_burn(p)
else
minetest.remove_node(p)
nodeupdate(p)
end
local node = minetest.get_node(p)
local def = minetest.registered_nodes[node.name]
if def.on_burn then
def.on_burn(p)
else
minetest.remove_node(p)
nodeupdate(p)
end
end
end,
Expand Down

0 comments on commit e5304ce

Please sign in to comment.