Skip to content

Commit 5dbc738

Browse files
Jat15BlockMen
authored andcommittedAug 7, 2014
Add API doors : Sound for door open and close.
1 parent 5b5aa49 commit 5dbc738

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed
 

‎game_api.txt

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ The doors mod allows modders to register custom doors.
4646
node_box_top = regular nodebox, see [Node boxes], OPTIONAL,
4747
selection_box_bottom = regular nodebox, see [Node boxes], OPTIONAL,
4848
selection_box_top = regular nodebox, see [Node boxes], OPTIONAL,
49+
sound_open_door = sound play for open door, OPTIONAL,
50+
sound_close_door = sound play for close door, OPTIONAL,
4951
only_placer_can_open = true/false,
5052
^ If true, only placer can open the door (locked for others)
5153
}

‎mods/doors/init.lua

+14-6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ function doors.register_door(name, def)
4646
def.selection_box_top = box
4747
end
4848

49+
if not def.sound_close_door then
50+
def.sound_close_door = "door_close"
51+
end
52+
if not def.sound_open_door then
53+
def.sound_open_door = "door_open"
54+
end
55+
56+
4957
minetest.register_craftitem(name, {
5058
description = def.description,
5159
inventory_image = def.inventory_image,
@@ -138,17 +146,17 @@ function doors.register_door(name, def)
138146
pos.y = pos.y-dir
139147
minetest.swap_node(pos, {name=replace, param2=p2})
140148

141-
local snd_1 = "_close"
142-
local snd_2 = "_open"
149+
local snd_1 = def.sound_close_door
150+
local snd_2 = def.sound_open_door
143151
if params[1] == 3 then
144-
snd_1 = "_open"
145-
snd_2 = "_close"
152+
snd_1 = def.sound_open_door
153+
snd_2 = def.sound_close_door
146154
end
147155

148156
if is_right(pos) then
149-
minetest.sound_play("door"..snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
157+
minetest.sound_play(snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
150158
else
151-
minetest.sound_play("door"..snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})
159+
minetest.sound_play(snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})
152160
end
153161
end
154162

0 commit comments

Comments
 (0)
Please sign in to comment.