Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candle on Sun 05/12/2004 01:34:30

Title: play soundfx every few mins
Post by: Candle on Sun 05/12/2004 01:34:30
How can have a sound play every few secs ?
I would like it to  do it in every room .
Title: Re: play soundfx every few mins
Post by: Pod on Sun 05/12/2004 04:12:33
in rerepetabldy execute, have a loop that runs every few seconds (use a time_Wait or whatever AGS calls them) that plays a sound.
Simple really!
Title: Re: play soundfx every few mins
Post by: Goot on Sun 05/12/2004 04:20:08
make a variable in the global script called time (time;)
in the global script:
function repeatedly_execute_always(){
time++;
if(time==x){//replace x with # of seconds x 40
time=0;
PlaySound(x);//replace x with sound #
}
}

if you are not using the lasest version of ags put the script in normal repeatedly execute, it won't run during blocking events.
Title: Re: play soundfx every few mins
Post by: Candle on Sun 05/12/2004 04:33:39
Would it look like this for the first variable  int  time; and where would I put it  in the script ?
Never mind I got it .. thank you for the help ..  ;D that worked great .
How could I add more sounds to that code so I could have more play at diff times ?
Just copy it and chane the time and x sound ?
Title: Re: play soundfx every few mins
Post by: Goot on Sun 05/12/2004 05:24:29
For multiple sounds that play at different times, do something like this:

function repeatedly_execute_always(){
time++;
if(time==x){
PlaySound(x);
}
else if(time==x){
PlaySound(x);
}
else if(time==x){
time=0;
PlaySound(x);
}
}
Title: Re: play soundfx every few mins
Post by: Candle on Sun 05/12/2004 05:38:53
Oh man that kicks butt. thank you so much for the help .