Fix door hardness detection for open/close sounds
authorZefram <zefram@fysh.org>
Thu, 7 Aug 2014 11:46:21 +0000 (13:46 +0200)
committerBlockMen <nmuelll@web.de>
Thu, 7 Aug 2014 11:47:01 +0000 (13:47 +0200)
mods/doors/init.lua

index 69416538901b36c90abb2262a35fcd4e663c85c5..808f5f7d3b15f6a3189c894f37ebc171580b43d5 100644 (file)
@@ -16,17 +16,6 @@ doors = {}
 --    only_placer_can_open: if true only the player who placed the door can
 --                          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)
        def.groups.not_in_creative_inventory = 1
@@ -104,6 +93,8 @@ function doors.register_door(name, def)
                        else
                                minetest.set_node(pt, {name=name.."_b_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
 
                        if def.only_placer_can_open then
@@ -153,7 +144,7 @@ function doors.register_door(name, def)
                        snd_2 = def.sound_close_door
                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})
                else
                        minetest.sound_play(snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})