Skip to content

Commit

Permalink
Fix door hardness detection for open/close sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Zefram authored and BlockMen committed Aug 7, 2014
1 parent 5dbc738 commit a1aee9a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions mods/doors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit a1aee9a

Please sign in to comment.