1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-22 23:10:17 +01:00

Open/close doors with rightclick

This commit is contained in:
PilzAdam 2013-01-04 17:02:46 +01:00
parent c27afe7ee8
commit 686c0d087c

View File

@ -96,7 +96,7 @@ function doors:register_door(name, def)
end end
end end
local function on_punch(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.env:get_node(pos).name == check_name then if not minetest.env:get_node(pos).name == check_name then
return return
@ -144,9 +144,9 @@ function doors:register_door(name, def)
after_dig_node(pos, name.."_t_1") after_dig_node(pos, name.."_t_1")
end, end,
on_punch = function(pos, node, puncher) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, puncher) then if check_player_priv(pos, clicker) then
on_punch(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0}) on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end end
end, end,
@ -174,9 +174,9 @@ function doors:register_door(name, def)
after_dig_node(pos, name.."_b_1") after_dig_node(pos, name.."_b_1")
end, end,
on_punch = function(pos, node, puncher) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, puncher) then if check_player_priv(pos, clicker) then
on_punch(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0}) on_rightclick(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2", {1,2,3,0})
end end
end, end,
@ -204,9 +204,9 @@ function doors:register_door(name, def)
after_dig_node(pos, name.."_t_2") after_dig_node(pos, name.."_t_2")
end, end,
on_punch = function(pos, node, puncher) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, puncher) then if check_player_priv(pos, clicker) then
on_punch(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2}) on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end end
end, end,
@ -234,9 +234,9 @@ function doors:register_door(name, def)
after_dig_node(pos, name.."_b_2") after_dig_node(pos, name.."_b_2")
end, end,
on_punch = function(pos, node, puncher) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, puncher) then if check_player_priv(pos, clicker) then
on_punch(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2}) on_rightclick(pos, -1, name.."_b_2", name.."_t_1", name.."_b_1", {3,0,1,2})
end end
end, end,