| Scripting Discuss scripting for SL and other platforms |
| |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Abundantia Owner ![]() Join Date: Sep 2009 Location: SL
Posts: 13
My Mood: | 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));
}
}
__________________ |
| | |
| | #2 (permalink) |
| Animates and Scripts ![]() Join Date: Oct 2009 Location: rural northeast US
Posts: 33
My Mood: SL Join Date: Sept 2006
Business: jeaniesing's things | 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
}
}
|
| | |
| 1 User Said Yay!: |
| 1 User Said Thanks: |
| 1 User Agreed: |
| | #4 (permalink) | |
| Scripter / Builder ![]() Join Date: Oct 2009
Posts: 4
My Mood: | Quote:
Still Looking for this part? If so, let me know...It can be done. -Steve. | |
| | |
| | #5 (permalink) | |
| Animates and Scripts ![]() Join Date: Oct 2009 Location: rural northeast US
Posts: 33
My Mood: SL Join Date: Sept 2006
Business: jeaniesing's things | Quote:
*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) | |
| | |
![]() |
| Tags |
| llsettimerevent, random, script, sound, timer |
| Thread Tools | |
| Display Modes | |
| |