Ignite TNT by fire

This commit is contained in:
Wuzzy 2020-05-09 18:52:03 +02:00
parent ffcad31871
commit 621946546b
2 changed files with 12 additions and 3 deletions

@ -132,14 +132,19 @@ minetest.register_node("mcl_fire:fire", {
end end
end end
else else
-- Replace flammable node with fire -- Burn flammable block
local nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y-1, z=pos.z-1}, {x=pos.x+1, y=pos.y+4, z=pos.z+1}, {"group:flammable"}) local nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y-1, z=pos.z-1}, {x=pos.x+1, y=pos.y+4, z=pos.z+1}, {"group:flammable"})
if #nodes > 0 then if #nodes > 0 then
local r = math.random(1, #nodes) local r = math.random(1, #nodes)
local ndef = minetest.registered_nodes[minetest.get_node(nodes[r]).name]
if ndef and ndef._on_burn then
ndef._on_burn(nodes[r])
else
spawn_fire(nodes[r], age_next) spawn_fire(nodes[r], age_next)
end end
end end
end end
end
-- Regular age increase -- Regular age increase
if age + age_add <= 15 then if age + age_add <= 15 then
node.param2 = age + age_add node.param2 = age + age_add

@ -67,7 +67,7 @@ minetest.register_node("mcl_tnt:tnt", {
_tt_help = S("Ignited by tools, explosions, fire, lava, redstone power").."\n"..S("Explosion radius: @1", tostring(TNT_RANGE)), _tt_help = S("Ignited by tools, explosions, fire, lava, redstone power").."\n"..S("Explosion radius: @1", tostring(TNT_RANGE)),
_doc_items_longdesc = longdesc, _doc_items_longdesc = longdesc,
_doc_items_usagehelp = S("Place the TNT and ignite it with one of the methods above. Quickly get in safe distance. The TNT will start to be affected by gravity and explodes in 4 seconds."), _doc_items_usagehelp = S("Place the TNT and ignite it with one of the methods above. Quickly get in safe distance. The TNT will start to be affected by gravity and explodes in 4 seconds."),
groups = { dig_immediate = 3, tnt = 1, enderman_takable=1 }, groups = { dig_immediate = 3, tnt = 1, enderman_takable=1, flammable=-1 },
mesecons = tnt_mesecons, mesecons = tnt_mesecons,
on_blast = function(pos) on_blast = function(pos)
local e = spawn_tnt(pos, "mcl_tnt:tnt") local e = spawn_tnt(pos, "mcl_tnt:tnt")
@ -78,6 +78,10 @@ minetest.register_node("mcl_tnt:tnt", {
tnt.ignite(pointed_thing.under) tnt.ignite(pointed_thing.under)
return true return true
end, end,
_on_burn = function(pos)
tnt.ignite(pos)
return true
end,
_on_dispense = function(stack, pos, droppos, dropnode, dropdir) _on_dispense = function(stack, pos, droppos, dropnode, dropdir)
-- Place and ignite TNT -- Place and ignite TNT
if minetest.registered_nodes[dropnode.name].buildable_to then if minetest.registered_nodes[dropnode.name].buildable_to then