random sound timer script needs "doctor"... - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » random sound timer script needs "doctor"...


Scripting Discuss scripting for SL and other platforms

Reply
 
LinkBack Thread Tools Display Modes
Old 10-14-2009, 10:07 PM   #1 (permalink)
Abundantia Owner
 
Yessika's Avatar
 
Join Date: Sep 2009
Location: SL
Posts: 13
My Mood:
Question random sound timer script needs "doctor"...

Hi again my fav smart scripting people....

I am trying to write a script which will play my sound-- the whole sound-- at random times (every 5 to 30 seconds).

It would be even better if it only played the sound when someone was within 10 meters of the object (without touch or collision)- but I have no idea if that sort of thing even exists.

Here's my script. Anyone know why it only plays part of the sound sometimes and why it doesn't take random breaks? (The silence always lasts 2.5 seconds- that's not random.)

Keep in mind please that I honestly don't know anything about scripting, but I have been trying very hard to learn by surfing here and the wiki.

Code:
float time = 15;
default
{
    state_entry()
    {
        llSetTimerEvent(10.0);
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        llPlaySound("MY-SOUND-UUID-HERE",0.5);
        llSetTimerEvent(llFrand(time));
    }
}
__________________
Yessika is offline   Reply With Quote
Old 10-14-2009, 10:52 PM   #2 (permalink)
Animates and Scripts
 
jeaniesing's Avatar
 
Join Date: Oct 2009
Location: rural northeast US
Posts: 33
My Mood:
SL Join Date: Sept 2006
Do you know how long the sound is? I believe a prim can only play one sound at a time, so maybe your randomized time is shorter than the sound itself and the 2.5 seconds is silent time at the end of the file...

try this?

Code:
float time = 15.0;
default
{
state_entry()
{
llSetTimerEvent(10.0);
}
 
timer()
{
llSetTimerEvent(0.0);
llPlaySound("MY-SOUND-UUID-HERE",0.5);
llSetTimerEvent(10.0+llFrand(time)); //minimum of ten seconds, max of 25... should allow the sound to stop and silence to happen in between
}
}
__________________
jeaniesing is offline   Reply With Quote
1 User Said Yay!:
1 User Said Thanks:
1 User Agreed:
Old 10-14-2009, 11:27 PM   #3 (permalink)
Abundantia Owner
 
Yessika's Avatar
 
Join Date: Sep 2009
Location: SL
Posts: 13
My Mood:
IT WORKS!!! YOU ARE AWESOME!!!

*dances around*

Quote:
Originally Posted by jeaniesing View Post
Do you know how long the sound is? I believe a prim can only play one sound at a time, so maybe your randomized time is shorter than the sound itself and the 2.5 seconds is silent time at the end of the file...
The sound is 9.98 seconds long.
Yessika is offline   Reply With Quote
Old 10-15-2009, 12:11 PM   #4 (permalink)
Scripter / Builder
 
Join Date: Oct 2009
Posts: 4
My Mood:
Quote:
It would be even better if it only played the sound when someone was within 10 meters of the object (without touch or collision)- but I have no idea if that sort of thing even exists.

Still Looking for this part? If so, let me know...It can be done.

-Steve.
Steven Broderick is offline   Reply With Quote
Old 10-15-2009, 02:40 PM   #5 (permalink)
Animates and Scripts
 
jeaniesing's Avatar
 
Join Date: Oct 2009
Location: rural northeast US
Posts: 33
My Mood:
SL Join Date: Sept 2006
Quote:
Originally Posted by Steven Broderick View Post
Still Looking for this part? If so, let me know...It can be done.
I agree, it can be done! But since the avatar is only gonna hear it at about a 5-10 meter range if the volume is appropriate, the sensor that checks for avatars will likely create more script lag than the tree falling in the woods when no one can hear?*





*translate: the sensor that checks for avatars will likely create more script lag than a sound playing on a timer that needs to be running, to some degree, anyway (llSensorRepeat being its own timer of sorts)
jeaniesing is offline   Reply With Quote
Old 10-15-2009, 03:00 PM   #6 (permalink)
Scripter / Builder
 
Join Date: Oct 2009
Posts: 4
My Mood:
Brilliance.

Quote:
Originally Posted by jeaniesing View Post
will likely create more script lag than the tree falling in the woods when no one can hear?
Haha, Beautifully stated. Definately agree.
Steven Broderick is offline   Reply With Quote
Reply

Tags
llsettimerevent, random, script, sound, timer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On