lilricecakes Posted June 23, 2020 Share Posted June 23, 2020 Is there a way to modify to have animations string together? If so i would love help on my first script integer ON = 0; //STATE OF SCRIPT //YOU EDIT THESE PARTS FOR NEW ANIMATIONS, SOUND CLIPS ETC. DO NOT TOUCH THE SCRIPT string animation = "Sync'D Motion__Originals - Boasty 01"; //ANIMATION NAME string animation = "Sync'D Motion__Originals - Boasty 02"; string animation = "Sync'D Motion__Originals - Boasty 03"; string animation = "Sync'D Motion__Originals - Boasty 04"; string animation = "Sync'D Motion__Originals - Boasty 05"; integer MaxSoundClips = 18; //AMOUNT OF SONG CLIPS, NAME THEM 1,2,3,4,ETC integer SoundLength = 10; //FIRST SERIES OF SOUND LENGTHS - MAX 10 SECS FLAT integer LastSoundLength = 8; //INCASE LAST SOUND CLIP IS SHORTER integer SoundClipNumber = 0; //FOR SOUND LOOP ResetToDefault() { llStopSound(); llSetTimerEvent(0.00); llStopAnimation(animation); 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() { llPlaySound((string)(++SoundClipNumber),1.0); if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;} 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; llStartAnimation(animation); llSetTimerEvent(0.01); } else if(message == "off"){ResetToDefault();} } } Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted June 23, 2020 Share Posted June 23, 2020 (edited) After your first assignment to the string animation, the subsequent attempts to declare it are causing the scope error, comment them out so that only one assignment to animation is being made. If you want to have several animations to select from, there are two ways: Quick and dirty, alter each successive animation variable to be animation1, animation2, etc Better, but you'll have to do some learning, Assign them to a list list animations = ["animation name", "animation name 2, "animation name 3" ]; // and so on // then where you would normally use the string variable, instead extract an item from the list llStartAnimation(llList2String(animations,2)); // will play the second item in the list Edited June 23, 2020 by Profaitchikenz Haiku 2 Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted June 23, 2020 Share Posted June 23, 2020 Expanding on what Profaitchikenz said: When you want to access a variable, you use the name you assigned when defining said variable. However in your case, you've defined several variables with the same name of "animation". Their contents are different, but the nametags are identical. If everyone has the same name, how do you tell them apart? Simply put, you can't and neither can the script - hence the error. That is why variables should each have a unique name. Side note: you can have duplicate names under certain conditions, if they are not in the same scope, such as a global variable vs a local variable. But that's not going to be very helpful in this case. Having a list of animations like Profaitchikenz suggests is going to work better than trying to use separate individual variables. It allows you to group related variables together and you can then pull them out one at a time and work with each one as needed. Also, if you are new to scripting, I would recommend looking through some of the guides and tutorials on the wiki to get the basics down. http://wiki.secondlife.com/wiki/Getting_started_with_LSL http://wiki.secondlife.com/wiki/LSL_101 Link to comment Share on other sites More sharing options...
lilricecakes Posted June 23, 2020 Author Share Posted June 23, 2020 8 hours ago, Profaitchikenz Haiku said: After your first assignment to the string animation, the subsequent attempts to declare it are causing the scope error, comment them out so that only one assignment to animation is being made. If you want to have several animations to select from, there are two ways: Quick and dirty, alter each successive animation variable to be animation1, animation2, etc Better, but you'll have to do some learning, Assign them to a list list animations = ["animation name", "animation name 2, "animation name 3" ]; // and so on // then where you would normally use the string variable, instead extract an item from the list llStartAnimation(llList2String(animations,2)); // will play the second item in the list so then in this case it will be ?? integer ON = 0; //STATE OF SCRIPT //YOU EDIT THESE PARTS FOR NEW ANIMATIONS, SOUND CLIPS ETC. DO NOT TOUCH THE SCRIPT list animations = ["animation name", "animation name 2, "animation name 3" ]; integer MaxSoundClips = 18; //AMOUNT OF SONG CLIPS, NAME THEM 1,2,3,4,ETC integer SoundLength = 10; //FIRST SERIES OF SOUND LENGTHS - MAX 10 SECS FLAT integer LastSoundLength = 8; //INCASE LAST SOUND CLIP IS SHORTER integer SoundClipNumber = 0; //FOR SOUND LOOP ResetToDefault() { llStopSound(); llSetTimerEvent(0.00); llStopAnimation(animation); 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() { llPlaySound((string)(++SoundClipNumber),1.0); if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;} 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; llStartAnimation(animation); llSetTimerEvent(0.01); } else if(message == "off"){ResetToDefault();} } } Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted June 23, 2020 Share Posted June 23, 2020 Three changes needed I omitted a trailing string quote in the list after "animation name 2 Second and third, everywhere you start and stop an animation, you need to replace the old string variable name animation with the extract from the list, so llStopAnimation(animation) needs to be changed to llStopAnimation(llList2String(animations,2)) and llStartAnimation(animation) changed to llStartAnimation(llList2String(animations,2)) Don't forget the semicolons, and watch out for getting odd numbers of curly brackets, quotes, and round brackets. Later on, once you get it working, it would be an idea to declare another integer variable calling something like animNumber and set it to 2, and then instead of hard-coding the number 2 in the lines where you pull the animation from the list, you use the variable animNum, which will then later on allow you to alter this while the script is running and so vary the particular animation that is to be used. Link to comment Share on other sites More sharing options...
lilricecakes Posted June 23, 2020 Author Share Posted June 23, 2020 15 minutes ago, Profaitchikenz Haiku said: Three changes needed I omitted a trailing string quote in the list after "animation name 2 Second and third, everywhere you start and stop an animation, you need to replace the old string variable name animation with the extract from the list, so llStopAnimation(animation) needs to be changed to llStopAnimation(llList2String(animations,2)) and llStartAnimation(animation) changed to llStartAnimation(llList2String(animations,2)) Don't forget the semicolons, and watch out for getting odd numbers of curly brackets, quotes, and round brackets. Later on, once you get it working, it would be an idea to declare another integer variable calling something like animNumber and set it to 2, and then instead of hard-coding the number 2 in the lines where you pull the animation from the list, you use the variable animNum, which will then later on allow you to alter this while the script is running and so vary the particular animation that is to be used. I really love the help! but i dont think im picking up much since i have very little experience in coding. This is a bit difficult for me Link to comment Share on other sites More sharing options...
Rolig Loon Posted June 23, 2020 Share Posted June 23, 2020 3 hours ago, Vortex10x said: really love the help! but i dont think im picking up much since i have very little experience in coding. This is a bit difficult for me That's likely to be the case, but don't let it discourage you. Take Fenix's advice and spend some time with one or two basic tutorials to get a feel for the structure and logical flow of a LSL script. Then spend a lot of time looking at examples of scripts. Pick short, easy ones to start. Read through them to see if you can understand what they do. Then, pick one and try changing it to do something a little different. You are likely to learn a lot more doing that than you are going to learn by watching what other people here do to make your mildly complicated script work. 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