fire: Document flammable group, a little code cleanup
authorHybridDog <ovvv@web.de>
Sat, 30 Mar 2019 20:33:08 +0000 (21:33 +0100)
committerParamat <paramat@users.noreply.github.com>
Sat, 30 Mar 2019 20:33:08 +0000 (20:33 +0000)
game_api.txt
mods/fire/init.lua

index b3bb3096d42af9a8bb72f55cdfc29452fff85dd2..61be13f5c4a7814a75293cde88e5c6dd6fe17dbe 100644 (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)`
index 612e052d99b5070262d37c2890b68f5efc4a19e1..9c36720abddd4ccbf71d735f0b597a8bf577c628 100644 (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,17 +337,18 @@ 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
-                               local flammable_node = minetest.get_node(p)
-                               local def = minetest.registered_nodes[flammable_node.name]
-                               if def.on_burn then
-                                       def.on_burn(p)
-                               else
-                                       minetest.remove_node(p)
-                                       minetest.check_for_falling(p)
-                               end
+                       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
+                               def.on_burn(p)
+                       else
+                               minetest.remove_node(p)
+                               minetest.check_for_falling(p)
                        end
                end,
        })