From 57b3f69d272d31ed161e1d376704e98e692e3f2e Mon Sep 17 00:00:00 2001 From: Ayane Satomi Date: Tue, 19 Apr 2022 01:08:34 +0800 Subject: [PATCH] Properly implement everything in PAC Signed-off-by: Ayane Satomi --- custom_taunts_with_audio.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/custom_taunts_with_audio.lua b/custom_taunts_with_audio.lua index 7fae732..1275154 100644 --- a/custom_taunts_with_audio.lua +++ b/custom_taunts_with_audio.lua @@ -36,13 +36,15 @@ function playMusic(music) -- FIXME: This doesn't know how to clean out music local audio = pac.CreatePart("mmd_audio_" .. tostring(music)) - audio:SetURL(tostring(music)) - audio:SetVolume(1) - audio:SetPitch(1) - audio:SetStopOnHide(true) - audio:SetPauseOnHide(true) + audio:SetPath(tostring(music)) audio:SetParent(self) -end + + for _, part in pairs(pac.GetLocalParts()) do + if part.ClassName == "group" then + part:SetParent(part) + break + end + end function cleanupAudio(music) local name = "mmd_audio_" .. tostring(music) @@ -63,5 +65,12 @@ function custom_taunts:OnDanceChanged(sid64, newdata) --FIXME: find a way to clean this out! playMusic(music) end + + if newdata.type == INFO_TYPES.Stop then + + for _, part in pairs(pac.GetLocalParts()) do + if string.find(part:Name(), "/mmd_music_([A-zA0-9])+/") == true pac.RemovePart(part) end + end + end end