I am planning a tutorial system with speech.
And would love to select which sound to play based on a variable.
I have the names of the soundfiles to play in an array.
But the “play sound” action cannot use a variable, only a selected soundfile.
I suppose there are many possibilities to do what you want.
First, you can use events to trigger a certain soundfile when condition is reached.
Second, if you are fluent with Javascript, you can use it to do the job.
In last, depending of the number of the soundfiles, you can employ variables which can be used to start the listening of soundfiles.
If you expose more precisions on your project, we will can certainly bring more infos.
There is an extension I built a while back called Sound ls and Music by Filename. You’ll need to ensure your sounds are loaded into the scene, but it should allow you to pass your filenames from your array.
Its in the community extension list in the engine.
Will try that extension - (to others looking for this: you will have to switch to “include experimental” when searching for the extension inside Gdevelop)