Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problem with llPlaySound()

Skilar Windlow
Registered User
Join date: 17 Nov 2008
Posts: 26
03-30-2009 18:49
I have an odd problem with llPlaySound() in a HUD I'm making. I have a HUD that will randomly choose a sound to play. For the most part it seems to work. But for some reason if I touch the button too quickly ... the next choosen sound file won't play. But it will play the same exact sound file correctly at other times. Definitely nothing wrong with the sound files themselves. Just not sure why sometimes the llPlaySound() doesn't engage. Am I not checking for something properly?

// Setup random number generator
integer random_integer( integer min, integer max )
{
return min + (integer)( llFrand( max - min + 1 ) );
}


default
{
state_entry()
{
}

touch_end(integer total_number)
{
// Find out how many sound files we have in the object and randomly select one
integer soundToUse = random_integer(0, llGetListLength(gSoundList)-1);

// Grab description for our selected sound file
llPlaySound(llList2String(gSoundList, soundToUse),1.0);
llSay(PUBLIC_CHANNEL, llList2String(gSoundTextList, soundToUse));

}
}

Skilar
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
03-30-2009 20:29
Have you tried this as an attachment? I don't think llPlaySound() works on attached objects, I believe you have to use llTriggerSound().
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Lennard Lopez
Registered User
Join date: 9 Oct 2007
Posts: 52
03-30-2009 22:08
Hi Skilor,

You choose a random sound. There is a chance that this algoritm picks the same sound twice. If you don't want the same sound twice:
CODE

integer last; // remember last played;
..
..
while
integer soundToUse;
do
soundToUse =random_integer(0, llGetListLength(gSoundList)-1);
while (soundToUse == last);
last=soundToUse;
..
..