fire: Document flammable group, a little code cleanup

This commit is contained in:
HybridDog 2019-03-30 21:33:08 +01:00 committed by Paramat
parent dfe6fd6560
commit efd090228d
2 changed files with 14 additions and 11 deletions

View File

@ -362,6 +362,8 @@ The farming API allows you to easily register plants and hoes.
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:
`on_burn(pos)`

View File

@ -320,7 +320,7 @@ if fire_enabled then
interval = 7,
chance = 12,
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"})
if p then
minetest.set_node(p, {name = "fire:basic_flame"})
@ -337,9 +337,11 @@ if fire_enabled then
interval = 5,
chance = 18,
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"})
if p then
if not p then
return
end
local flammable_node = minetest.get_node(p)
local def = minetest.registered_nodes[flammable_node.name]
if def.on_burn then
@ -348,7 +350,6 @@ if fire_enabled then
minetest.remove_node(p)
minetest.check_for_falling(p)
end
end
end,
})