From 67449e63495dea49a16b3b3ac6eb39a20107f616 Mon Sep 17 00:00:00 2001 From: cheapie Date: Wed, 24 Apr 2024 18:35:56 -0500 Subject: Add door open/close sounds --- doors.lua | 24 ++++++++++++++++++++++++ sounds/celevator_door_close.ogg | Bin 0 -> 54709 bytes sounds/celevator_door_open.ogg | Bin 0 -> 40696 bytes sounds/celevator_door_reverse.ogg | Bin 0 -> 17991 bytes 4 files changed, 24 insertions(+) create mode 100644 sounds/celevator_door_close.ogg create mode 100644 sounds/celevator_door_open.ogg create mode 100644 sounds/celevator_door_reverse.ogg diff --git a/doors.lua b/doors.lua index f4c20c9..26e95b1 100644 --- a/doors.lua +++ b/doors.lua @@ -516,12 +516,31 @@ function celevator.doors.caropen(pos) time = 0, opendir = vector.rotate_around_axis(fdir,vector.new(0,1,0),-math.pi/2), } + minetest.sound_play("celevator_door_open",{ + pos = pos, + gain = 0.4, + max_hear_distance = 10 + },true) celevator.doors.erefs[hash] = erefs celevator.storage:set_string("cardoors_moving",minetest.serialize(cardoors_moving)) local meta = celevator.get_meta(pos) meta:set_string("doordata",minetest.serialize(cardoors_moving[hash])) meta:set_string("doorstate","opening") elseif cardoors_moving[hash].direction == "close" then + if cardoors_moving[hash].soundhandle then + minetest.sound_stop(cardoors_moving[hash].soundhandle) + end + minetest.sound_play("celevator_door_reverse",{ + pos = pos, + gain = 1, + max_hear_distance = 10 + },true) + minetest.sound_play("celevator_door_open",{ + pos = pos, + gain = 0.4, + start_time = math.max(0,2.75-cardoors_moving[hash].time), + max_hear_distance = 10 + },true) cardoors_moving[hash].direction = "open" cardoors_moving[hash].time = math.pi-cardoors_moving[hash].time celevator.storage:set_string("cardoors_moving",minetest.serialize(cardoors_moving)) @@ -552,6 +571,11 @@ function celevator.doors.carclose(pos) erefs[i]:set_pos(vector.add(erefs[i]:get_pos(),soffset)) end celevator.doors.erefs[hash] = erefs + data.soundhandle = minetest.sound_play("celevator_door_close",{ + pos = pos, + gain = 0.3, + max_hear_distance = 10 + }) cardoors_moving[hash] = data celevator.storage:set_string("cardoors_moving",minetest.serialize(cardoors_moving)) end diff --git a/sounds/celevator_door_close.ogg b/sounds/celevator_door_close.ogg new file mode 100644 index 0000000..d4153c5 Binary files /dev/null and b/sounds/celevator_door_close.ogg differ diff --git a/sounds/celevator_door_open.ogg b/sounds/celevator_door_open.ogg new file mode 100644 index 0000000..0070be5 Binary files /dev/null and b/sounds/celevator_door_open.ogg differ diff --git a/sounds/celevator_door_reverse.ogg b/sounds/celevator_door_reverse.ogg new file mode 100644 index 0000000..4f93391 Binary files /dev/null and b/sounds/celevator_door_reverse.ogg differ -- cgit v1.2.3