mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-31 02:56:26 -04:00
Destroy doors completely on on_blast event
This commit is contained in:
parent
52aaf85194
commit
0c6fdbdd05
1 changed files with 31 additions and 8 deletions
|
@ -25,10 +25,6 @@ function doors.register_door(name, def)
|
||||||
if not def.sound_open_door then
|
if not def.sound_open_door then
|
||||||
def.sound_open_door = "doors_door_open"
|
def.sound_open_door = "doors_door_open"
|
||||||
end
|
end
|
||||||
if def.only_placer_can_open then
|
|
||||||
-- unaffected by explosions
|
|
||||||
def.on_blast = function() end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craftitem(name, {
|
minetest.register_craftitem(name, {
|
||||||
|
@ -112,6 +108,33 @@ function doors.register_door(name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function check_and_blast(pos, name)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node.name == name then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function make_on_blast(base_name, door_type, other_door_type)
|
||||||
|
if def.only_placer_can_open then
|
||||||
|
return function() end
|
||||||
|
else
|
||||||
|
if door_type == "_b_1" or door_type == "_b_2" then
|
||||||
|
return function(pos, intensity)
|
||||||
|
check_and_blast(pos, name..door_type)
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
check_and_blast(pos, name..other_door_type)
|
||||||
|
end
|
||||||
|
elseif door_type == "_t_1" or door_type == "_t_2" then
|
||||||
|
return function(pos, intensity)
|
||||||
|
check_and_blast(pos, name..door_type)
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
check_and_blast(pos, name..other_door_type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||||
pos.y = pos.y+dir
|
pos.y = pos.y+dir
|
||||||
if not minetest.get_node(pos).name == check_name then
|
if not minetest.get_node(pos).name == check_name then
|
||||||
|
@ -178,7 +201,7 @@ function doors.register_door(name, def)
|
||||||
can_dig = check_player_priv,
|
can_dig = check_player_priv,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = def.on_blast,
|
on_blast = make_on_blast(name, "_b_1", "_t_1")
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name.."_t_1", {
|
minetest.register_node(name.."_t_1", {
|
||||||
|
@ -211,7 +234,7 @@ function doors.register_door(name, def)
|
||||||
can_dig = check_player_priv,
|
can_dig = check_player_priv,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = def.on_blast,
|
on_blast = make_on_blast(name, "_t_1", "_b_1")
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name.."_b_2", {
|
minetest.register_node(name.."_b_2", {
|
||||||
|
@ -244,7 +267,7 @@ function doors.register_door(name, def)
|
||||||
can_dig = check_player_priv,
|
can_dig = check_player_priv,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = def.on_blast,
|
on_blast = make_on_blast(name, "_b_2", "_t_2")
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name.."_t_2", {
|
minetest.register_node(name.."_t_2", {
|
||||||
|
@ -277,7 +300,7 @@ function doors.register_door(name, def)
|
||||||
can_dig = check_player_priv,
|
can_dig = check_player_priv,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
sunlight_propagates = def.sunlight,
|
sunlight_propagates = def.sunlight,
|
||||||
on_blast = def.on_blast,
|
on_blast = make_on_blast(name, "_t_2", "_b_2")
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue