Vladimir0si0atat Posted April 4, 2015 Share Posted April 4, 2015 So this script is turning into alpha all prims that are linked together.Can anyone help me to find out how to make it work just for some prims and not all.Like set it work just for the prims with a certain name an not all child prims?float randomized_time = 0.5; // experiment with this timefloat animation_speed = 0.5;integer total_prims;integer link_counter;action(){ llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); llSetLinkAlpha( link_counter,1.0, ALL_SIDES);}default{ state_entry() { total_prims = llGetNumberOfPrims(); state warmup; }}state warmup{ state_entry() { state trigger; } changed( integer c) { if ( c & CHANGED_LINK) { llResetScript(); } }} Link to comment Share on other sites More sharing options...
Xiija Posted April 4, 2015 Share Posted April 4, 2015 you'd need a list and 2 "for" loops? one 'for' loop to get the link names or numbers, and one to set the alphas... list linkNumbers; integer n; integer len = llGetNumberOfPrims(); for(;n<len;++n) { if( llGetLinkName(n) == "setMeAlpha") { linkNumbers += n; } } integer x; integer len2 = llGetListLength(linkNumbers); for(;x < len2;++x) { llSetLinkAlpha( llList2Integer( linkNumbers,x), 0.0, ALL_SIDES); } // or something like that? Link to comment Share on other sites More sharing options...
Vladimir0si0atat Posted April 5, 2015 Author Share Posted April 5, 2015 Thank you so much for your answer Xija.seems that it gives a syntax error Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 5, 2015 Share Posted April 5, 2015 The LSL Scripting forum is a place for scripters to share ideas and learn from each other's successes and failures. We don't typically provide complete scripts as answers here,and Xijia's answer is not a complete script. If you try to run it by itself, it will naturally fail. It is an example of the sort of coding that you need to include in your own script to do what you're asking about. Having said that, yes ... Xijia's example does have a small typo. The line llSetLinkAlpha( llList2Integer( linkNumbers,n) 0.0, ALL_SIDES); is missing a comma before 0.0 . :smileywink: Link to comment Share on other sites More sharing options...
Vladimir0si0atat Posted April 5, 2015 Author Share Posted April 5, 2015 Thank you for your reply Rolling Loon.Yes I do know that Scripting forum is a place for scripters to share ideas and learn from each other's successes and failures.I Never forced anyone to reply to my question exactly from that reason.I simply ask because there are no decent scripting classes in world which is why I'm trying to learn by myself.It shows the error where the integer len = llGetNumberOfPrims(); is.If my question offended or seemed like anyone is obliged to help I will gladly delete my question. Link to comment Share on other sites More sharing options...
Xiija Posted April 5, 2015 Share Posted April 5, 2015 hi sorry , i can't offer advice if i can't see your script? i posted a snippet beause your original post was also a snippet... your error is most likely a missing ; somewhere ? yell if ya need more help p.s. ( fixed 2 typos in orig msg ... comma and n should have been x) Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 6, 2015 Share Posted April 6, 2015 Noooo... No offense taken or intended. I gave my answer because it was not clear whether you understood that Xijia's example was only a snippet, not a complete script. We frequently get questions from people who make that mistake and are surprised when a posted snippet doesn't work. There's no error in Xijia's code snippet at that point, so it's probably something before that in your own script that's causing it. As Xijia said, it would be easier to see where they might be it you posted the whole script, or at least the part that you're trying to rewrite. Link to comment Share on other sites More sharing options...
Vladimir0si0atat Posted April 6, 2015 Author Share Posted April 6, 2015 Xija that is the whole script here is a link to make it more clear :https://www.youtube.com/watch?v=HayC32mAaE0 as you can see all those 3 models are animated.I would be interested to make another model linked to those three that will not be animated Link to comment Share on other sites More sharing options...
Vladimir0si0atat Posted April 6, 2015 Author Share Posted April 6, 2015 Roling Loon I understood that Xija's example is a snippet. I just did not want to seem needy or wasting anyones time since coding should indeed be paid cus it's a lot of work and knowledge needed.I tried to modify the original script that I posted in my question with Xija's snippet and somehow something went wrong.I just posted in a reply to her the video with the tutorial on youtube to show how that script works.I think you are right and something might be wrong at my script. Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 6, 2015 Share Posted April 6, 2015 Now that I see what you're trying to do, it's actually easier to simply show you a sample script that illustrates the basic idea. As Xijia said, the task is in two parts. One part is to identify the links that you will want to animate. The second is to animate them. The first part is done once, in state_entry. The second part is handled in a timer, which will cycle through the links you identified in task One. Anything else (a toggle switch, a reset in case you change the linkset ... ) has nothing to do with that basic two-part logic. When you set out to write a script, always whittle down your idea to basic logical tasks like this. Code each part as a self-contained module, then be sure that you have ways to pass important information from one module to another. Then finally add any bells and whistles to make the script pretty. Especially in a simple script like this, the separate code "modules" often turn out to be separate events or states, each of which can be written on its own. float animation_speed = 0.5;integer link_counter;integer gON; // A toggle switchlist gModel_list; // List of your animated link numbersinteger gLen; // Length of gModel_listdefault{ state_entry() // In which you make a list of the links to be animated { integer i = llGetNumberOfPrims(); while (i) { if (llGetLinkName(i) == "Model") // Find the links named "Model" { gModel_list += [i]; // Add them to a list } --i; } gLen = llGetListLength(gModel_list); // How long is the list? } changed( integer c) { if ( c & CHANGED_LINK) { llResetScript(); } } touch_start(integer num) // In which you turn animation On/Off { llSetTimerEvent(animation_speed* (gON = !gON)); link_counter = 0; } timer() // In which you animate the links { link_counter = (++link_counter)%gLen; // Choose the next link in gModel_list, a new one each time the timer fires integer i; while ( i < gLen) // Step through all links listed in gModel_list { integer Link = llList2Integer(gModel_list,i); // Get the link number if ( i == link_counter) // If this link is the one chosen ..... { llSetLinkAlpha(Link, 1.0, ALL_SIDES); // ... make it visible } else { llSetLinkAlpha( Link,0.0, ALL_SIDES); /// .... make it transparent } ++i; } } } Link to comment Share on other sites More sharing options...
Vladimir0si0atat Posted April 7, 2015 Author Share Posted April 7, 2015 Thank you so much.I am really glad you also written the explanations on each line so I could understand what is going on.My model is working perfectly Link to comment Share on other sites More sharing options...
Sebjust Posted January 7, 2016 Share Posted January 7, 2016 Something i doing wrong with that script:( i have 8 linked object and want animate with alpha script only 4 from them with names "obj1", "obj2", "obj3" and "obj4". I need first visible "obj1" then it will alpha and "obj2" will visible and etc. I removed from script only: touch_start(integer num) // In which you turn animation On/Off { llSetTimerEvent(animation_speed* (gON = !gON)); link_counter = 0; because i don't need to touch object. i will wear it. i get this: float animation_speed = 0.5;integer link_counter;list gModel_list=["obj1", "obj2", "obj3", "obj4"]; // List of your animated link numbersinteger gLen; // Length of gModel_list default{state_entry() // In which you make a list of the links to be animated{integer i = llGetNumberOfPrims();while (i){if (llGetLinkName(i) == "obj1") // Find the links named "Model"{gModel_list += ; // Add them to a list}--i;}gLen = llGetListLength(gModel_list); // How long is the list?} changed( integer c){if ( c & CHANGED_LINK){llResetScript();}}timer() // In which you animate the links{link_counter = (++link_counter)%gLen; // Choose the next link in gModel_list, a new one each time the timer firesinteger i;while ( i < gLen) // Step through all links listed in gModel_list{integer Link = llList2Integer(gModel_list,i); // Get the link numberif ( i == link_counter) // If this link is the one chosen .....{llSetLinkAlpha(Link, 1.0, ALL_SIDES); // ... make it visible}else{llSetLinkAlpha( Link,0.0, ALL_SIDES); /// .... make it transparent}++i;}}} i don't get error but script not work. Could you please write where i was wrong? Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 7, 2016 Share Posted January 7, 2016 Many places, starting with the global definition of gModel_list at the top of your script. If you put names in there, you are messing up the whole point of having that list. It's a list of link numbers, loaded in the loop that's in your state_entry event (which you have also messed up by loading it only with the link number for the link named "obj1"). Then you have all of the execution in the timer event, correctly, but you have deleted the switch that turns the timer on, so that will never run. If you are going to modify someone else's script instead of writing your own, be very sure that you understand its logic before you fiddle with it. Link to comment Share on other sites More sharing options...
Sebjust Posted January 7, 2016 Share Posted January 7, 2016 Thank you for reply. Now script work fine. How i can wear object and running script automaticaly? i mean not touch on it for on/off Link to comment Share on other sites More sharing options...
steph Arnott Posted January 7, 2016 Share Posted January 7, 2016 "How i can wear object and running script automaticaly?" what does this mean? Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 7, 2016 Share Posted January 7, 2016 If you want to trigger the timer event when you wear it, put the trigger in an attach event instead of putting it in the touch_start event where I had it originally. Link to comment Share on other sites More sharing options...
Sebjust Posted January 7, 2016 Share Posted January 7, 2016 Thank you very much!! It is work now 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