Run function after X miliseconds [message #417956] |
Mon, 18 January 2010 10:35 |
|
Omar007
Messages: 1711 Registered: December 2007 Location: Amsterdam
Karma:
|
General (1 Star) |
|
|
I currently have a piece of code that will run Function A on level loaded
This function initiates Function B a little later.
In Function B im getting the length of an MP3 file (in miliseconds)
After this, Function B has to run again after that time, while any other code still runs.
Problem is i cant use Sleep(); or w/e to wait that long because all other code must continue running.
Afaik i cant make it a script either (so i can use Start_Timer + Timer_Expired) that will be attached to a player because it'll will then restart the whole code after every die (AKA object change)
void FunctionA()
{
//Code here; read file containing sounds
FunctionB();
}
void FunctionB()
{
if(runnow)
{
//Pick a random song from the file
//Play the song
fsystem->update();
{
//Set Volume
//Get song length (in miliseconds)
}
FunctionB(); //This should run after 'song length' above
}
//More code; should still run and not only after X miliseconds as Sleep(); would do
}
If needed i'll upload the whole file
EDIT:
i believe in Javascript you have something like setInterval() that does what i want
EDIT2:
Oh and if anyone knows how to get the music volume settings from renegade, please tell ^^
[Updated on: Mon, 18 January 2010 10:42] Report message to a moderator
|
|
|