Mewkyuu

Drake

Dec 16th, 2011
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. http://mp3splt.sourceforge.net/mp3splt_page/home.php
  2.  
  3. LoadMusic(track);
  4. PlayMusic(track);
  5.  
  6. let min = 0;
  7. let sec = 0;
  8. let cen = 0;
  9. //current time, starts at 0'0"0
  10. let loopmin = 3;
  11. let loopsec = 42;
  12. let loopcen = 58;
  13. //time to loop at
  14.  
  15. @MainLoop{
  16.  
  17. cen++; //every frame, cen will increase
  18. if (frame % 60 == 0){sec++;} //every 60 frames, sec will increase
  19. if (frame == 3600){min++; frame = 0;} //every 3600 frames (or 60 seconds), min will increase
  20.  
  21. if (cen == loopcen && sec == loopsec && min == loopmin){ //if you're at the loop time
  22. LoadMusic(looptrack);
  23. PlayMusic(looptrack); //play the split track
  24. loopmin = 1;
  25. loopsec = 23;
  26. loopcen = 54;
  27. min = 0;
  28. sec = 0;
  29. cen = 0;
  30. //reset the current time and change the time to loop at
  31. }
  32.  
  33. }
  34.  
  35. /////////////////////////////////////////////////////////////////////
  36.  
  37. 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).
  38.  
  39. 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:
  40. time_to_restart_at = time_loop_started + (minutes * 60000) + (seconds * 1000) + milliseconds
  41.  
  42. The just do a simple check to see if you should restart the loop:
  43. if (GetTime() > time_to_restart_at) <restart the loop>;
  44.  
  45. 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.
  46.  
  47.  
  48.  
  49. 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!
  50.  
  51.  
  52. 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