Log In  

Hi there, this is my first post.

I wonder how can i execute a command when a music or sfx is done (i mean when it has been played).
Do you have any suggestion ? thanks in advance

P#55147 2018-08-14 15:43 ( Edited 2018-08-16 21:32)

Welcome! :) What you're asking to do is a little tricky but can definitely be done.

For SFX, you can use stat 16-19 to find out which SFX is playing on each channel (you can explicitly set the channel when calling sfx so you know which channel to look at). So you could, for example:

  1. call sfx(8, 0)
  2. repeatedly (on successive frames) call stat(16) until it no longer returns 8
  3. at this point you know the SFX stopped playing

It would be similar for music, but you'd use stat(24), although there is currently a bug with that (if the music you care about is at index 0) which I have previously reported

For more info, here are the SFX/Music stat numbers from the manual:

        16..19  Index of currently playing SFX on channels 0..3
        20..23  Note number (0..31) on channel 0..3
        24      Currently playing pattern index
        25      Total patterns played
        26      Ticks played on current pattern
P#55245 2018-08-16 13:39 ( Edited 2018-08-16 17:40)

Awesome ! thanks a lot kittenm4ster :)

P#55267 2018-08-16 17:32 ( Edited 2018-08-16 21:32)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 14:03:49 | 0.011s | Q:13