by qwertymine3 » Wed Oct 28, 2015 23:31
If you only want one block playing (or positionless music) at any given time, AFAIK this shouldn't be too hard.
When you play a sound with minetest.sound_play it should return a 'handle' (a reference to the sound). You can put this in a global variable (just create a variable outside a function) and test that the global is not nil to know if the music is playing. If it is you can then use minetest.sound_stop to stop the music and then set the global to nil.
You may also have to check the song hasn't finished using some form of timer or check against os.clock (store the start time in a global), as I don't think the handle is automatically deleted when the song ends, but I may be wrong.
I haven't tried this, but hopefully this is correct.
Avatar by :devnko-ennekappao: