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



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:
- call
sfx(8, 0)
- repeatedly (on successive frames) call
stat(16)
until it no longer returns8
- 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 |
[Please log in to post a comment]