|
Nyles Nestler
Registered User
Join date: 5 Jan 2008
Posts: 72
|
02-02-2008 14:24
Hello again, Yet another installment in this series of annoying questions..... I have written a script that plays a sound (looped) in an object: string sound = "bounce"; default { touch_start(integer t) { llLoopSound(sound, 1.0); } }
After I rez this object, and touch it, that sound plays looped as expected. After deleting the rezzed obj, then rezzing a new one from my inv, the sound is still playing.... What would be the proper syntax to add a llStopSound() call this script? (upon clicking it again) Thanks in Advance!
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-02-2008 16:45
integer gBooPlaying;
default{ touch_start( integer vIntTouched ){ do{ --vIntTouched;
if (gBooPlaying){ //-- stop sound loop }else{ //-- start sound loop } gBooPlaying = !gBooPlaying;
}while (vIntTouched); } }
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Nyles Nestler
Registered User
Join date: 5 Jan 2008
Posts: 72
|
02-02-2008 17:26
Thanks for the reply Void!
I'm a bit confused though.... I *am* new to LSL and haven't played with any scripting languages to any extent for a few years now...all this, compounded by my lack of sleep is effectively rendering me a block-head.... I see here we've got an if - else conditional statement nested inside a do - while loop, and I see where you've commented the area that turns on and off the sound but I don't see any call to actually play the sound (????) Maybe I'm missing something....is this script supposed to be *additional* to my script or is it meant to replace it? Sorry for bothering.... I really appreciate the help.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-02-2008 19:14
His comments basically mean, "put your code to start and stop the sounds here." That would mean starting the sound as you did, and using llStopSound() where you want to stop it. His example toggles the sound state each time a person touches the object (though he may want to just use 'vIntTouched%2' instead of a loop  ). Another idea that could be used instead or in addition is to call llStopSound() from the 'on_rez' event. Careful to update global variables in all places if you are still going to use them to track whether the sound is playing or not.
|
|
Nyles Nestler
Registered User
Join date: 5 Jan 2008
Posts: 72
|
02-02-2008 20:21
Thanks Hewee! I did as you said - it works fine. I appreciate your help!
|
|
Nyles Nestler
Registered User
Join date: 5 Jan 2008
Posts: 72
|
02-02-2008 20:22
I have no idea where the above tags came from......very weird....
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-02-2008 20:34
the loop is to process all touches that the event collects (for instance if it's busy processing other code, all touches will queue together untill the touch start event is processed) it's not an absolute neccessity...
the if statement if the key there, if the sound is playing it stops it, if it's not playing it starts it.
to clarify what HeeWee meant by (vIntTouches % 2) instead of a loop is, if there are an even number of touches, ignore them all (since an even number would put it right back to where it was, either playing or not)... which would work for a toggle, but not for more general purposes. I assumed there would eventually be other code to go with this, so stuck with the general purpose case of processing them all.
PS for the record it's 'she', no harm no foul, =) but I do begin to see why certain posters don't bother defining their gender heh
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-02-2008 21:26
From: Void Singer for the record it's 'she', no harm no foul, =) but I do begin to see why certain posters don't bother defining their gender heh My apologies!
|