Skip to content
Snippets Groups Projects
Commit efd09022 authored by HybridDog's avatar HybridDog Committed by Paramat
Browse files

fire: Document flammable group, a little code cleanup

parent dfe6fd65
No related branches found
No related tags found
No related merge requests found
...@@ -362,6 +362,8 @@ The farming API allows you to easily register plants and hoes. ...@@ -362,6 +362,8 @@ The farming API allows you to easily register plants and hoes.
Fire API Fire API
-------- --------
Add group flammable when registering a node to make fire seek for it.
Add it to an item to make it burn up when dropped in lava or fire.
New node def property: New node def property:
`on_burn(pos)` `on_burn(pos)`
......
...@@ -320,7 +320,7 @@ if fire_enabled then ...@@ -320,7 +320,7 @@ if fire_enabled then
interval = 7, interval = 7,
chance = 12, chance = 12,
catch_up = false, catch_up = false,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos)
local p = minetest.find_node_near(pos, 1, {"air"}) local p = minetest.find_node_near(pos, 1, {"air"})
if p then if p then
minetest.set_node(p, {name = "fire:basic_flame"}) minetest.set_node(p, {name = "fire:basic_flame"})
...@@ -337,17 +337,18 @@ if fire_enabled then ...@@ -337,17 +337,18 @@ if fire_enabled then
interval = 5, interval = 5,
chance = 18, chance = 18,
catch_up = false, catch_up = false,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos)
local p = minetest.find_node_near(pos, 1, {"group:flammable"}) local p = minetest.find_node_near(pos, 1, {"group:flammable"})
if p then if not p then
local flammable_node = minetest.get_node(p) return
local def = minetest.registered_nodes[flammable_node.name] end
if def.on_burn then local flammable_node = minetest.get_node(p)
def.on_burn(p) local def = minetest.registered_nodes[flammable_node.name]
else if def.on_burn then
minetest.remove_node(p) def.on_burn(p)
minetest.check_for_falling(p) else
end minetest.remove_node(p)
minetest.check_for_falling(p)
end end
end, end,
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment