Page 1 of 1

IsMusicIDLoaded(n)

Posted: Sun Oct 27, 2024 2:32 pm
by Bugala
I just noticed there is no way to check if some specific music ID is actually loaded or not.

This isn't a big deal, but I have this very simple function, which is part of Music related functions:

Code: Select all

Function p_Music.Stop()
StopMusic(1)
EndFunction
However, I just realized there can come a situation where this p_Music.Stop() is called before any music is loaded, which crashes it.

So I started Looking for something like IsMusicIDLoaded, but couldn't find one.

This means that either I have to load some music into ID 1 myself, even I never play it, or I have to have some sort of Variable which keeps info whether this ID 1 is occupied or not, and then check it before using StopMusic(1).

Would be handy to have something like IsMusicIDLoaded(n)

Re: IsMusicIDLoaded(n)

Posted: Sun Oct 27, 2024 5:44 pm
by Flinx
This is the begin of my Stop function:

Code: Select all

Function p_StopMusic(m)
	If HaveObject(#MUSIC, m)
		If IsMusicPlaying(m) Then StopMusic(m)

Re: IsMusicIDLoaded(n)

Posted: Sun Oct 27, 2024 7:59 pm
by Bugala
Thanks! I didn't realize such a thing already existed.