diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index d5aa9d01..4f8c3e5a 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -6,6 +6,7 @@ Cleans up the table for the next scenario in a campaign: --]] local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") +local soundCubeApi = require("core/SoundCubeApi") -- enable this for debugging local SHOW_RAYS = false @@ -165,7 +166,7 @@ function cleanUp(_, color) printToAll("Clean up started!", "Orange") printToAll("Resetting counters...", "White") - triggerSoundCube() + soundCubeApi.playSoundByName("Vacuum") ignoreCustomDataHelper() getTrauma() updateCounters(DAMAGE_HORROR_GUIDS, RESET_VALUES, "Damage / Horror") @@ -185,14 +186,6 @@ end --------------------------------------------------------- -- modular functions, called by other functions --------------------------------------------------------- - -function triggerSoundCube() - local soundCube = getObjectsWithTag("SoundCube")[1] - if soundCube then - soundCube.AssetBundle.playTriggerEffect(0) - end -end - function updateCounters(tableOfGUIDs, tableOfNewValues, info) if tonumber(tableOfNewValues) then local value = tableOfNewValues diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 1a099b0a..e27ea4db 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -34,6 +34,7 @@ local hideTitleSplashWaitFunctionId = nil local playmatApi = require("playermat/PlaymatApi") local tokenManager = require("core/token/TokenManager") local playAreaAPI = require("core/PlayAreaApi") +local soundCubeApi = require("core/SoundCubeApi") --------------------------------------------------------- -- data for tokens @@ -1021,10 +1022,6 @@ function titleSplash(scenarioName) hideTitleSplashWaitFunctionId = nil end, 4) - -- play bell sound from soundCube - local soundCube = getObjectsWithTag("SoundCube")[1] - if soundCube then - soundCube.AssetBundle.playTriggerEffect(1) - end + soundCubeApi.playSoundByName("Deep Bell") end end diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua new file mode 100644 index 00000000..06273524 --- /dev/null +++ b/src/core/SoundCubeApi.ttslua @@ -0,0 +1,17 @@ +do + local SoundCubeApi = {} + + -- this table links the name of a trigger effect to its index + local soundIndices = { + ["Vacuum"] = 0, + ["Deep Bell"] = 1 + } + + -- plays the by name requested sound + ---@param soundName String Name of the sound to play + SoundCubeApi.playSoundByName = function(soundName) + getObjectsWithTag("SoundCube")[1].AssetBundle.playTriggerEffect(soundIndices[soundName]) + end + + return SoundCubeApi +end