I changed it to Loop instead of Play, so it doesn't end. Pretty key.
How can I get activating the script again to stop the current song from playing? Currently, with that script, if the next song is different it will play on top. If the randomly selected song is the same, then it will stop and restart it. I don't know what command tells the global sounds to end.
Edit: Figured it out. Enter this for each global sound added. Put it before you trigger the next song.
StopGlobalSound(1)
StopGlobalSound(2)
etc
So, this is working so far:
in the init section:
LoadGlobalSound( "audiobank\\music\\1.wav", 1 )
LoadGlobalSound( "audiobank\\music\\2.wav", 2 )
in the main section:
if PlayerDist < 90 then
StopGlobalSound(1)
StopGlobalSound(2)
LoopGlobalSound( math.random ( 1, 2 ) )
Destroy(e)
end
So if you're using 100 sound effects or songs or whatnot, you'd have to have 100 lines saying to stop each of the global sounds that can possibly play, since you don't know what's playing and this code doesn't cover that.