Fire: Optimize spreading ABM.
No need to find_node_near twice with the same params.master
parent
28884cc784
commit
e5304ce674
|
@ -254,22 +254,20 @@ else
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(p0, node, _, _)
|
action = function(p0, node, _, _)
|
||||||
-- If there are no flammable nodes around flame, remove flame
|
-- 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)
|
minetest.remove_node(p0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if math.random(1, 4) == 1 then
|
if math.random(1, 4) == 1 then
|
||||||
-- remove flammable nodes around flame
|
-- remove flammable nodes around flame
|
||||||
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
|
local node = minetest.get_node(p)
|
||||||
if p then
|
local def = minetest.registered_nodes[node.name]
|
||||||
local node = minetest.get_node(p)
|
if def.on_burn then
|
||||||
local def = minetest.registered_nodes[node.name]
|
def.on_burn(p)
|
||||||
if def.on_burn then
|
else
|
||||||
def.on_burn(p)
|
minetest.remove_node(p)
|
||||||
else
|
nodeupdate(p)
|
||||||
minetest.remove_node(p)
|
|
||||||
nodeupdate(p)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue