Skip to content

Commit a814abd

Browse files
author
Jeija
committedNov 22, 2014
Merge branch 'doorsounds'
2 parents fb5c9ed + 1908a22 commit a814abd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

Diff for: ‎mesecons_compatibility/init.lua

+24
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ doors = {}
1515
-- selection_box_top
1616
-- only_placer_can_open: if true only the player who placed the door can
1717
-- open it
18+
local function is_right(pos)
19+
local r1 = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
20+
local r2 = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
21+
if string.find(r1.name, "door_") or string.find(r2.name, "door_") then
22+
if string.find(r1.name, "_1") or string.find(r2.name, "_1") then
23+
return true
24+
else
25+
return false
26+
end
27+
end
28+
end
1829

1930
function doors:register_door(name, def)
2031
def.groups.not_in_creative_inventory = 1
@@ -59,6 +70,19 @@ function doors:register_door(name, def)
5970
meta = minetest.get_meta(pos):to_table()
6071
minetest.set_node(pos, {name=replace, param2=p2})
6172
minetest.get_meta(pos):from_table(meta)
73+
74+
local snd_1 = "_close"
75+
local snd_2 = "_open"
76+
if params[1] == 3 then
77+
snd_1 = "_open"
78+
snd_2 = "_close"
79+
end
80+
81+
if is_right(pos) then
82+
minetest.sound_play("door"..snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
83+
else
84+
minetest.sound_play("door"..snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})
85+
end
6286
end
6387

6488
local function on_mesecons_signal_open (pos, node)

0 commit comments

Comments
 (0)
Please sign in to comment.