|
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
|
06-09-2006 07:19
Im Need To Put A Touch On And Off On This Script Can Some Tell Me The Command Etc To Add ? list sounds = ["American Oriole","bird1.wav","bird2.wav","birdprey.wav","birds.wav","Cardinal","Red-tailed Hawk","Tree Swallow","frog.wav"];// this is where you would put the names // of the sounds. make sure that they are exact!!! integer x; default { state_entry() { llSetTimerEvent(60.0); // generate a timer event every 1 second } timer() { x = llFloor( llFrand( llGetListLength(sounds) ) );// This will pick // a random sound based on the number of sounds that are in the list llSound(llList2String(sounds, x), 1, 0, 0);// so long as the sound is in the objects inventory, it should work } }
|
|
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
06-09-2006 07:51
Try this..I am not in-world now so I have not tested this. By the way, llSetTimerEvent should be set to 1 for one second..not 60 as in your code. Change the value of the timerInterval variable near the top of the script to change the interval between sounds. // modified by 2fast4u Nabob [20060609] - added touch on/off functionality
list sounds = ["American Oriole","bird1.wav","bird2.wav","birdprey.wav","birds.wav","Cardinal","Red-tailed Hawk","Tree Swallow","frog.wav"];// this is where you would put the names // of the sounds. make sure that they are exact!!!
float timerInterval=1.0; //enter the number of seconds between sounds here integer x; integer isOn=FALSE;
default { state_entry() { llSetTimerEvent(timerInterval); // generate a timer event every 1 second }
touch_start(integer num_detected) { isOn = !isOn; if(!isOn) llSetTimerEvent(0); else llSetTimerEvent(timerInterval); }
timer() { x = llFloor( llFrand( llGetListLength(sounds) ) );// This will pick // a random sound based on the number of sounds that are in the list llSound(llList2String(sounds, x), 1, 0, 0);// so long as the sound is in the objects inventory, it should work } }
|
|
Azreal Rubio
PrimHead
Join date: 29 Jan 2004
Posts: 194
|
How about using states?
06-09-2006 09:10
How about using states? list sounds = ["American Oriole","bird1.wav","bird2.wav","birdprey.wav","birds.wav","Cardinal","Red-tailed Hawk","Tree Swallow","frog.wav"];// this is where you would put the names // of the sounds. make sure that they are exact!!! integer x;
default { touch_start (integer touch_num) { state Running; } }
state Running { state_entry() { llSetTimerEvent(60.0); // generate a timer event every 1 minute }
touch_start(integer touch_num) { state default; } timer() { x = llFloor( llFrand( llGetListLength(sounds) ) );// This will pick // a random sound based on the number of sounds that are in the list llSound(llList2String(sounds, x), 1, 0, 0);// so long as the sound is in the objects inventory, it should work } }
|
|
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
06-09-2006 09:23
From: Azreal Rubio How about using states? Cool...much more elegant and only 1 call to llSetTimerEvent...nice 
|
|
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
|
06-09-2006 09:44
tyvm  ..... and i made it 60 sec cause i didnt want them chirpin etc constantly here and there is nice 
|