Why does this function crash any trigger it is called in?

Status
Not open for further replies.
Level 14
Joined
Oct 18, 2013
Messages
743
Code:
function PlayMusicExt takes string Normal, string External returns nothing
local integer i=0
local string s
       loop
        exitwhen i>11
                if GetLocalPlayer()== Player(i) then
           if GetSoundFileDuration(External) > 0 then
          set s=External
          else
          set s=Normal
          endif
          endif
        call StopMusic(false)  
        call PlayMusic(s)
        set i=i+1
      endloop
endfunction

If I call this using 2 strings (1 of an imported file, the 2nd of another mp3 in a folder players would have to import)

While testing in single player, events after calling this function won't happen, IF Music is off. I'm guessing its something with PlayMusic, just speculation. I might have to disect this function and try to findout what exactly causes this.

edit: I moved these two lines to after the loop, where they should've been.
Code:
        call StopMusic(false)  
        call PlayMusic(s)
and now I don't see the bug anymore. Seems odd, all that was added was those two lines running 10 more times than they otherwise would. I don't know if that would crash the thread (or w.e the name of it is that keeps all trigs running with the cap of ~8192 actions)
 
Last edited:
Ah, after the first run? So can it be after the loop, or does playing the music have to be in the same bit that I set s?
 
Status
Not open for further replies.
Back
Top