Skip to content

Commit

Permalink
Added support for on_blast callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy committed Sep 24, 2013
1 parent d6a0b7d commit 4427d79
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
local destroy = function(pos)
local nodename = minetest.env:get_node(pos).name
if nodename ~= "air" then
minetest.env:remove_node(pos)
local on_blast = minetest.registered_nodes[nodename].on_blast
if on_blast ~= nil then
on_blast(pos, 1) -- the intensity of TNT is defined to be 1
return
else
minetest.env:remove_node(pos)
end
nodeupdate(pos)
if minetest.registered_nodes[nodename].groups.flammable ~= nil then
minetest.env:set_node(pos, {name="fire:basic_flame"})
Expand Down Expand Up @@ -68,10 +74,7 @@ boom = function(pos, time)
pos.z = pos.z+dz

local node = minetest.env:get_node(pos)
if node.name == "tnt:tnt" or node.name == "tnt:tnt_burning" then
minetest.env:set_node(pos, {name="tnt:tnt_burning"})
boom({x=pos.x, y=pos.y, z=pos.z}, 0)
elseif node.name == "fire:basic_flame" or string.find(node.name, "default:water_") or string.find(node.name, "default:lava_") or node.name == "tnt:boom" then
if node.name == "fire:basic_flame" or string.find(node.name, "default:water_") or string.find(node.name, "default:lava_") or node.name == "tnt:boom" then

else
if math.abs(dx)<2 and math.abs(dy)<2 and math.abs(dz)<2 then
Expand Down Expand Up @@ -122,6 +125,11 @@ minetest.register_node("tnt:tnt", {
boom(pos, 4)
end
end,

on_blast = function(pos, intensity)
minetest.env:set_node(pos, {name="tnt:tnt_burning"})
boom({x=pos.x, y=pos.y, z=pos.z}, 0)
end,

mesecons = {
effector = {
Expand All @@ -138,6 +146,9 @@ minetest.register_node("tnt:tnt_burning", {
light_source = 5,
drop = "",
sounds = default.node_sound_wood_defaults(),
on_blast = function(pos, intensity)
boom({x=pos.x, y=pos.y, z=pos.z}, 0)
end,
})

minetest.register_node("tnt:boom", {
Expand Down

0 comments on commit 4427d79

Please sign in to comment.