From 5dbc738dbda2e552b800a295c14b0a0949de19d9 Mon Sep 17 00:00:00 2001
From: Jat <jinan15@hotmail.com>
Date: Mon, 4 Aug 2014 18:28:09 +0200
Subject: [PATCH] Add API doors : Sound for door open and close.

---
 game_api.txt        |  2 ++
 mods/doors/init.lua | 20 ++++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/game_api.txt b/game_api.txt
index 3d9d7a59..4eb2d782 100644
--- a/game_api.txt
+++ b/game_api.txt
@@ -46,6 +46,8 @@ The doors mod allows modders to register custom doors.
 	node_box_top = regular nodebox, see [Node boxes], OPTIONAL,
 	selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
 	selection_box_top = regular nodebox, see [Node boxes], OPTIONAL,
+	sound_open_door = sound play for open door, OPTIONAL,
+	sound_close_door = sound play for close door, OPTIONAL,
 	only_placer_can_open = true/false,
 	^ If true, only placer can open the door (locked for others)
 }
diff --git a/mods/doors/init.lua b/mods/doors/init.lua
index bb327b85..69416538 100644
--- a/mods/doors/init.lua
+++ b/mods/doors/init.lua
@@ -46,6 +46,14 @@ function doors.register_door(name, def)
 		def.selection_box_top = box
 	end
 
+	if not def.sound_close_door then
+		def.sound_close_door = "door_close"
+	end
+	if not def.sound_open_door then
+		def.sound_open_door = "door_open"
+	end
+	
+	
 	minetest.register_craftitem(name, {
 		description = def.description,
 		inventory_image = def.inventory_image,
@@ -138,17 +146,17 @@ function doors.register_door(name, def)
 		pos.y = pos.y-dir
 		minetest.swap_node(pos, {name=replace, param2=p2})
 
-		local snd_1 = "_close"
-		local snd_2 = "_open"
+		local snd_1 = def.sound_close_door
+		local snd_2 = def.sound_open_door 
 		if params[1] == 3 then
-			snd_1 = "_open"
-			snd_2 = "_close"
+			snd_1 = def.sound_open_door 
+			snd_2 = def.sound_close_door
 		end
 
 		if is_right(pos) then
-			minetest.sound_play("door"..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
-			minetest.sound_play("door"..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})
 		end
 	end
 
-- 
GitLab