Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://mp3splt.sourceforge.net/mp3splt_page/home.php
- LoadMusic(track);
- PlayMusic(track);
- let min = 0;
- let sec = 0;
- let cen = 0;
- //current time, starts at 0'0"0
- let loopmin = 3;
- let loopsec = 42;
- let loopcen = 58;
- //time to loop at
- @MainLoop{
- cen++; //every frame, cen will increase
- if (frame % 60 == 0){sec++;} //every 60 frames, sec will increase
- if (frame == 3600){min++; frame = 0;} //every 3600 frames (or 60 seconds), min will increase
- if (cen == loopcen && sec == loopsec && min == loopmin){ //if you're at the loop time
- LoadMusic(looptrack);
- PlayMusic(looptrack); //play the split track
- loopmin = 1;
- loopsec = 23;
- loopcen = 54;
- min = 0;
- sec = 0;
- cen = 0;
- //reset the current time and change the time to loop at
- }
- }
- /////////////////////////////////////////////////////////////////////
- A good idea, Drake. One suggestion, though: It may be better to use the GetTime() function instead of counting frames. If the game starts experiencing slowdown, your counter will start lagging behind, resulting in a late restart of the loop (it could happen the other way, too, if the game starts playing too fast for some reason).
- This function gives you the time, in milliseconds, that the script has been running. All you need to do is keep track of when you started the current loop, and check for when it should be restarted using this simple formula:
- time_to_restart_at = time_loop_started + (minutes * 60000) + (seconds * 1000) + milliseconds
- The just do a simple check to see if you should restart the loop:
- if (GetTime() > time_to_restart_at) <restart the loop>;
- This still won't be perfect, since it only gets called once per frame and has the possibility of not lining up perfectly with the music, but if you set it up right it should be good.
- I've been making extensive use of this type of stuff in a new, secret project which I'll never finish cause I'm a lazy dumbass[s]I've been a bit too busy to work on effectively[/s]. Hopefully I'll find motivation to finish it up soon!
- I should mention, though - I highly recommend against using GetTime() for anything related to the actual gameplay normally, since that will very likely break replays (since the timing could very well be different each time it is run).
Advertisement
Add Comment
Please, Sign In to add comment