Allison Lynagh Posted November 26, 2013 Share Posted November 26, 2013 So, I've managed to hobble together a few codes from various scripts and gotten what I want.. almost. This is a dancer and sound player (A single song with animations that cycle sequentially according to a list). But I've somewhere failed, as the sound cycle is linked to the animation cycle. I kinda need the sound timer event and the animation timer event to be two seperate things so I can have the animation cycle at increments longer than 10 seconds. Any help would be superbly appreciated.I've determined the line of scripting that needs help (directly below) but I'm not exactly sure how to have 2 timer events triggered at the same time. timer() { ++gDance; if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;} llStopAnimation(Allison); integer i = gDance %llGetListLength(dances); Allison = llList2String(dances,i); llStartAnimation(Allison); llPlaySound((string)(++SoundClipNumber),1.0); if(SoundClipNumber == MaxSoundClips){llSetTimerEvent(LastSoundLength); ON = 1; SoundClipNumber = 0;} llPreloadSound((string)(SoundClipNumber+1)); } integer ON = 0; //STATE OF SCRIPT integer MaxSoundClips = 18; //AMOUNT OF SONG CLIPS, NAME THEM 1,2,3,4,ETC integer SoundLength = 10; //FIRST SERIES OF SOUND LENGTHS integer LastSoundLength = 2; //INCASE LAST SOUND CLIP IS SHORTER integer SoundClipNumber = 0; //FOR SOUND LOOP integer gDance; list dances = [ "dance1", "dance2", "dance3" ]; //LIST DANCES HERE, "Name of Dance", (no comma after last dance string Allison; ResetToDefault() { llStopSound(); llSetTimerEvent(0.00); llStopAnimation(Allison); ON = 0; SoundClipNumber = 0; } default { state_entry() { llListen(0, "", "", ""); } attach(key id) { if(id) { llOwnerSay(" Commands 'on' or 'off'"); llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); } else ResetToDefault(); } timer() { ++gDance; if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;} llStopAnimation(Allison); integer i = gDance %llGetListLength(dances); Allison = llList2String(dances,i); llStartAnimation(Allison); llPlaySound((string)(++SoundClipNumber),1.0); if(SoundClipNumber == MaxSoundClips){llSetTimerEvent(LastSoundLength); ON = 1; SoundClipNumber = 0;} llPreloadSound((string)(SoundClipNumber+1)); } listen(integer channel, string name, key id, string message) { message = llToLower(message); if (ON == 0 && message == "on") { ON = 1; Allison = "sit"; //DEFAULT STARTING ANIM, CHANGE IF YOU LIKE llStartAnimation(Allison); llSetTimerEvent(0.5); //THIS SETS TIME BEFORE THE DANCER KICKS IN } else if(message == "off"){ResetToDefault();} } } Link to comment Share on other sites More sharing options...
Amethyst Jetaime Posted November 26, 2013 Share Posted November 26, 2013 You can have only one timer event active at a time in a script. So this isn't going to work. You will need two scripts, one for the music, one for the animation. Link to comment Share on other sites More sharing options...
April Looming Posted November 26, 2013 Share Posted November 26, 2013 You can have a timer event do more than one thing though. They just won't happen at exactly the same tame. I've seen SL take a LONG time to load sounds initially, so playing sounds and sync with animation can be a real problem. The first / second / third time through, the anim may play with no sound. Link to comment Share on other sites More sharing options...
Ron Khondji Posted November 26, 2013 Share Posted November 26, 2013 A 1 second timer in combination with a counter might be what you need.Like this: integer seconds;default{ state_entry(){ llSetTimerEvent(1.0); } timer(){ ++seconds; if (seconds == 5){ // do something after 5 seconds } if (seconds == 7){ // do something after 7 seconds } seconds = 0; }} Link to comment Share on other sites More sharing options...
LepreKhaun Posted November 26, 2013 Share Posted November 26, 2013 Allison Lynagh wrote: So, I've managed to hobble together a few codes from various scripts and gotten what I want.. almost. This is a dancer and sound player (A single song with animations that cycle sequentially according to a list). But I've somewhere failed, as the sound cycle is linked to the animation cycle. I kinda need the sound timer event and the animation timer event to be two seperate things so I can have the animation cycle at increments longer than 10 seconds. Any help would be superbly appreciated. I've determined the line of scripting that needs help (directly below) but I'm not exactly sure how to have 2 timer events triggered at the same time. timer() { ++gDance; if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;} llStopAnimation(Allison); integer i = gDance %llGetListLength(dances); Allison = llList2String(dances,i); llStartAnimation(Allison); llPlaySound((string)(++SoundClipNumber),1.0); if(SoundClipNumber == MaxSoundClips){llSetTimerEvent(LastSoundLength); ON = 1; SoundClipNumber = 0;} llPreloadSound((string)(SoundClipNumber+1)); } integer ON = 0; //STATE OF SCRIPTinteger MaxSoundClips = 18; //AMOUNT OF SONG CLIPS, NAME THEM 1,2,3,4,ETC integer SoundLength = 10; //FIRST SERIES OF SOUND LENGTHSinteger LastSoundLength = 2; //INCASE LAST SOUND CLIP IS SHORTERinteger SoundClipNumber = 0; //FOR SOUND LOOPinteger gDance;list dances = [ "dance1", "dance2", "dance3" ]; //LIST DANCES HERE, "Name of Dance", (no comma after last dancestring Allison;ResetToDefault(){ llStopSound(); llSetTimerEvent(0.00); llStopAnimation(Allison); ON = 0; SoundClipNumber = 0;} default{ state_entry() { llListen(0, "", "", ""); } attach(key id) { if(id) { llOwnerSay(" Commands 'on' or 'off'"); llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); } else ResetToDefault(); } timer() { ++gDance; if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;} llStopAnimation(Allison); integer i = gDance %llGetListLength(dances); Allison = llList2String(dances,i); llStartAnimation(Allison); llPlaySound((string)(++SoundClipNumber),1.0); if(SoundClipNumber == MaxSoundClips){llSetTimerEvent(LastSoundLength); ON = 1; SoundClipNumber = 0;} llPreloadSound((string)(SoundClipNumber+1)); } listen(integer channel, string name, key id, string message) { message = llToLower(message); if (ON == 0 && message == "on") { ON = 1; Allison = "sit"; //DEFAULT STARTING ANIM, CHANGE IF YOU LIKE llStartAnimation(Allison); llSetTimerEvent(0.5); //THIS SETS TIME BEFORE THE DANCER KICKS IN } else if(message == "off"){ResetToDefault();} }} Deja vu code- http://community.secondlife.com/t5/LSL-Scripting/Need-script/m-p/1964773#M16753 [Edit to point more directly to the script I recognized.] Link to comment Share on other sites More sharing options...
Allison Lynagh Posted November 27, 2013 Author Share Posted November 27, 2013 Yes, that was the starting point, but as you can see, I've tormented the poor script greatly to try to acheive what I want. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now