Fix door hardness detection for open/close sounds

This commit is contained in:
Zefram 2014-08-07 13:46:21 +02:00 committed by BlockMen
parent 5dbc738dbd
commit a1aee9a68f
1 changed files with 3 additions and 12 deletions

View File

@ -16,17 +16,6 @@ doors = {}
-- only_placer_can_open: if true only the player who placed the door can -- only_placer_can_open: if true only the player who placed the door can
-- open it -- open it
local function is_right(pos)
local r1 = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
local r2 = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
if string.find(r1.name, "door_") or string.find(r2.name, "door_") then
if string.find(r1.name, "_1") or string.find(r2.name, "_1") then
return true
else
return false
end
end
end
function doors.register_door(name, def) function doors.register_door(name, def)
def.groups.not_in_creative_inventory = 1 def.groups.not_in_creative_inventory = 1
@ -104,6 +93,8 @@ function doors.register_door(name, def)
else else
minetest.set_node(pt, {name=name.."_b_2", param2=p2}) minetest.set_node(pt, {name=name.."_b_2", param2=p2})
minetest.set_node(pt2, {name=name.."_t_2", param2=p2}) minetest.set_node(pt2, {name=name.."_t_2", param2=p2})
minetest.get_meta(pt):set_int("right", 1)
minetest.get_meta(pt2):set_int("right", 1)
end end
if def.only_placer_can_open then if def.only_placer_can_open then
@ -153,7 +144,7 @@ function doors.register_door(name, def)
snd_2 = def.sound_close_door snd_2 = def.sound_close_door
end end
if is_right(pos) then if minetest.get_meta(pos):get_int("right") ~= 0 then
minetest.sound_play(snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10}) minetest.sound_play(snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
else else
minetest.sound_play(snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10}) minetest.sound_play(snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})