mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-23 07:10:19 +01:00
De-duplicate code in doors mod in make_on_blast
This commit is contained in:
parent
4bd1094619
commit
81259e9fcc
@ -115,22 +115,14 @@ function doors.register_door(name, def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make_on_blast(base_name, door_type, other_door_type)
|
local function make_on_blast(base_name, dir, door_type, other_door_type)
|
||||||
if def.only_placer_can_open then
|
if def.only_placer_can_open then
|
||||||
return function() end
|
return function() end
|
||||||
else
|
else
|
||||||
if door_type == "_b_1" or door_type == "_b_2" then
|
return function(pos, intensity)
|
||||||
return function(pos, intensity)
|
check_and_blast(pos, base_name .. door_type)
|
||||||
check_and_blast(pos, base_name .. door_type)
|
pos.y = pos.y + dir
|
||||||
pos.y = pos.y + 1
|
check_and_blast(pos, base_name .. other_door_type)
|
||||||
check_and_blast(pos, base_name .. other_door_type)
|
|
||||||
end
|
|
||||||
elseif door_type == "_t_1" or door_type == "_t_2" then
|
|
||||||
return function(pos, intensity)
|
|
||||||
check_and_blast(pos, base_name .. door_type)
|
|
||||||
pos.y = pos.y - 1
|
|
||||||
check_and_blast(pos, base_name .. other_door_type)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -201,7 +193,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 = make_on_blast(name, "_b_1", "_t_1")
|
on_blast = make_on_blast(name, 1, "_b_1", "_t_1")
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name.."_t_1", {
|
minetest.register_node(name.."_t_1", {
|
||||||
@ -234,7 +226,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 = make_on_blast(name, "_t_1", "_b_1")
|
on_blast = make_on_blast(name, -1, "_t_1", "_b_1")
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name.."_b_2", {
|
minetest.register_node(name.."_b_2", {
|
||||||
@ -267,7 +259,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 = make_on_blast(name, "_b_2", "_t_2")
|
on_blast = make_on_blast(name, 1, "_b_2", "_t_2")
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(name.."_t_2", {
|
minetest.register_node(name.."_t_2", {
|
||||||
@ -300,7 +292,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 = make_on_blast(name, "_t_2", "_b_2")
|
on_blast = make_on_blast(name, -1, "_t_2", "_b_2")
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user