summaryrefslogtreecommitdiff
path: root/mesecons_compatibility
diff options
context:
space:
mode:
authorMartin Doege <mdoege@compuserve.com>2014-07-14 20:43:06 +0200
committerMartin Doege <mdoege@compuserve.com>2014-07-14 20:43:06 +0200
commit1908a225f941adc8509f5681eeede1f4abbdad4f (patch)
tree8788c38b5df6a123920b525578556422573f2a29 /mesecons_compatibility
parent0c62545a3a29e759c5152202244e00e5bcbd5601 (diff)
downloadmesecons-1908a225f941adc8509f5681eeede1f4abbdad4f.tar
mesecons-1908a225f941adc8509f5681eeede1f4abbdad4f.tar.gz
mesecons-1908a225f941adc8509f5681eeede1f4abbdad4f.tar.bz2
mesecons-1908a225f941adc8509f5681eeede1f4abbdad4f.tar.xz
mesecons-1908a225f941adc8509f5681eeede1f4abbdad4f.zip
add door sounds from minetest_game
Diffstat (limited to 'mesecons_compatibility')
-rw-r--r--mesecons_compatibility/init.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/mesecons_compatibility/init.lua b/mesecons_compatibility/init.lua
index 5bdce27..0ad04b2 100644
--- a/mesecons_compatibility/init.lua
+++ b/mesecons_compatibility/init.lua
@@ -15,6 +15,17 @@ doors = {}
-- selection_box_top
-- 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
@@ -59,6 +70,19 @@ function doors:register_door(name, def)
meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace, param2=p2})
minetest.get_meta(pos):from_table(meta)
+
+ local snd_1 = "_close"
+ local snd_2 = "_open"
+ if params[1] == 3 then
+ snd_1 = "_open"
+ snd_2 = "_close"
+ end
+
+ if is_right(pos) then
+ minetest.sound_play("door"..snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
+ else
+ minetest.sound_play("door"..snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})
+ end
end
local function on_mesecons_signal_open (pos, node)