mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-28 17:46:28 -04:00
Make TNT respect on_blast, implement on_blast for some nodes
Implemented nodes: - Steel Door: Ignores explosion - Locked Chest: Ignores explosion - Fire: Ignores explosion - TNT: Starts burning - Burning TNT: Explodes immediately - Gunpowder: Starts burning - Burning Gunpowder: Ignores explosion
This commit is contained in:
parent
41837e6193
commit
47636791b1
4 changed files with 33 additions and 19 deletions
|
@ -1234,6 +1234,7 @@ minetest.register_node("default:chest_locked", {
|
|||
)
|
||||
end
|
||||
end,
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ function doors.register_door(name, def)
|
|||
if not def.sound_open_door then
|
||||
def.sound_open_door = "doors_door_open"
|
||||
end
|
||||
if def.only_placer_can_open then
|
||||
def.on_blast = function() end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_craftitem(name, {
|
||||
|
@ -173,7 +176,8 @@ function doors.register_door(name, def)
|
|||
|
||||
can_dig = check_player_priv,
|
||||
sounds = def.sounds,
|
||||
sunlight_propagates = def.sunlight
|
||||
sunlight_propagates = def.sunlight,
|
||||
on_blast = def.on_blast,
|
||||
})
|
||||
|
||||
minetest.register_node(name.."_t_1", {
|
||||
|
@ -205,7 +209,8 @@ function doors.register_door(name, def)
|
|||
|
||||
can_dig = check_player_priv,
|
||||
sounds = def.sounds,
|
||||
sunlight_propagates = def.sunlight,
|
||||
sunlight_propagates = def.sunlight,
|
||||
on_blast = def.on_blast,
|
||||
})
|
||||
|
||||
minetest.register_node(name.."_b_2", {
|
||||
|
@ -237,7 +242,8 @@ function doors.register_door(name, def)
|
|||
|
||||
can_dig = check_player_priv,
|
||||
sounds = def.sounds,
|
||||
sunlight_propagates = def.sunlight
|
||||
sunlight_propagates = def.sunlight,
|
||||
on_blast = def.on_blast,
|
||||
})
|
||||
|
||||
minetest.register_node(name.."_t_2", {
|
||||
|
@ -269,7 +275,8 @@ function doors.register_door(name, def)
|
|||
|
||||
can_dig = check_player_priv,
|
||||
sounds = def.sounds,
|
||||
sunlight_propagates = def.sunlight
|
||||
sunlight_propagates = def.sunlight,
|
||||
on_blast = def.on_blast,
|
||||
})
|
||||
|
||||
end
|
||||
|
|
|
@ -24,6 +24,8 @@ minetest.register_node("fire:basic_flame", {
|
|||
on_destruct = function(pos)
|
||||
minetest.after(0, fire.on_flame_remove_at, pos)
|
||||
end,
|
||||
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
fire.D = 6
|
||||
|
|
|
@ -82,7 +82,14 @@ local function destroy(drops, pos, cid)
|
|||
if def and def.flammable then
|
||||
minetest.set_node(pos, fire_node)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
local nodename = minetest.get_node(pos).name
|
||||
local on_blast = minetest.registered_nodes[nodename].on_blast
|
||||
if on_blast ~= nil then
|
||||
on_blast(pos, 1)
|
||||
return
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
if def then
|
||||
local node_drops = minetest.get_node_drops(def.name, "")
|
||||
for _, item in ipairs(node_drops) do
|
||||
|
@ -172,12 +179,6 @@ local function explode(pos, radius)
|
|||
local p = {}
|
||||
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_tnt = minetest.get_content_id("tnt:tnt")
|
||||
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
||||
local c_gunpowder = minetest.get_content_id("tnt:gunpowder")
|
||||
local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning")
|
||||
local c_boom = minetest.get_content_id("tnt:boom")
|
||||
local c_fire = minetest.get_content_id("fire:basic_flame")
|
||||
|
||||
for z = -radius, radius do
|
||||
for y = -radius, radius do
|
||||
|
@ -189,13 +190,7 @@ local function explode(pos, radius)
|
|||
p.x = pos.x + x
|
||||
p.y = pos.y + y
|
||||
p.z = pos.z + z
|
||||
if cid == c_tnt or cid == c_gunpowder then
|
||||
burn(p)
|
||||
elseif cid ~= c_tnt_burning and
|
||||
cid ~= c_gunpowder_burning and
|
||||
cid ~= c_air and
|
||||
cid ~= c_fire and
|
||||
cid ~= c_boom then
|
||||
if cid ~= c_air then
|
||||
destroy(drops, p, cid)
|
||||
end
|
||||
end
|
||||
|
@ -231,6 +226,9 @@ minetest.register_node("tnt:tnt", {
|
|||
minetest.get_node_timer(pos):start(4)
|
||||
end
|
||||
end,
|
||||
on_blast = function(pos, intensity)
|
||||
burn(pos)
|
||||
end,
|
||||
mesecons = {effector = {action_on = boom}},
|
||||
})
|
||||
|
||||
|
@ -250,6 +248,7 @@ minetest.register_node("tnt:tnt_burning", {
|
|||
drop = "",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_timer = boom,
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:boom", {
|
||||
|
@ -262,6 +261,7 @@ minetest.register_node("tnt:boom", {
|
|||
on_timer = function(pos, elapsed)
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:gunpowder", {
|
||||
|
@ -285,6 +285,9 @@ minetest.register_node("tnt:gunpowder", {
|
|||
burn(pos)
|
||||
end
|
||||
end,
|
||||
on_blast = function(pos, intensity)
|
||||
burn(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:gunpowder_burning", {
|
||||
|
@ -324,7 +327,8 @@ minetest.register_node("tnt:gunpowder_burning", {
|
|||
end
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
|
|
Loading…
Add table
Reference in a new issue