Max Pitre Posted January 30, 2016 Share Posted January 30, 2016 How can I use all the prims in a linkset except the root prim? I'm thinking llGetNumberOfPrims but keep the root prim out of the picture, just not sure how.Original scriptfloat animation_speed = 0.15; integer total_prims; integer link_counter; default { state_entry() { total_prims = llGetNumberOfPrims(); llSetTimerEvent(animation_speed ); } timer() { link_counter++; llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); llSetLinkAlpha( link_counter,1.0, ALL_SIDES); if( link_counter == total_prims) { link_counter = 0; } } } Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 30, 2016 Share Posted January 30, 2016 Um.... total_prims = llGetNumberOfPrims() - 1 maybe? :smileywink: And start counting with prim #2 instead of #1. BTW, it will be much easier for you to edit your own work if you use standard indenting and keep to one statement per line. 1 Link to comment Share on other sites More sharing options...
Max Pitre Posted January 30, 2016 Author Share Posted January 30, 2016 Thanks, will try that and thanks for the reminder too edit: Worked perfect... :matte-motes-big-grin: Link to comment Share on other sites More sharing options...
steph Arnott Posted January 31, 2016 Share Posted January 31, 2016 Seems a complicated way of just doing this. float animation_speed = 0.15;integer total_prims;integer link_counter;default{ state_entry() { total_prims = llGetNumberOfPrims(); llSetTimerEvent(animation_speed ); } timer() { llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES); llSetLinkAlpha( link_counter,1.0, ALL_SIDES); if( link_counter == total_prims) { link_counter = 0; } link_counter++; }} Link to comment Share on other sites More sharing options...
steph Arnott Posted January 31, 2016 Share Posted January 31, 2016 lost me om on that one ma. Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 31, 2016 Share Posted January 31, 2016 Yup. That's another way to do exactly the same thing. Either one will work. If you want yet another way, try float animation_speed = 0.15;integer link_counter;integer total_prims;default{ state_entry() { llSetTimerEvent(animation_speed ); total_prims = llGetNumberOfPrims(); } timer() { llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES); llSetLinkAlpha( ++link_counter%total_prims,1.0, ALL_SIDES); }} There are usually several ways to script the same problem. Link to comment Share on other sites More sharing options...
steph Arnott Posted January 31, 2016 Share Posted January 31, 2016 :smileywink: Link to comment Share on other sites More sharing options...
starverse Posted February 3, 2016 Share Posted February 3, 2016 As I recall, llGetNumberOfPrims () returns the total number of prims. Link 0 is reserved for "all prims" Link 1 is the root prim. First non-root prim is link #2 So you need a loop that looks more like this (SLIGHT change to previous poster's code): float animation_speed = 0.15;integer link_counter;integer total_prims;default{ state_entry() { llSetTimerEvent(animation_speed ); total_prims = llGetNumberOfPrims(); } timer() { llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES); llSetLinkAlpha( ++link_counter% (total_prims + 1),1.0, ALL_SIDES); // total_prims + 1 is needed in modulus to get the last prim if (link_counter < 2) // Make sure the prim pointer is neither LINK_SET nor LINK_ROOT link_counter = 2; }} Link to comment Share on other sites More sharing options...
steph Arnott Posted February 3, 2016 Share Posted February 3, 2016 As the OP just wanted to ignore the root prim, LINK_ALL_CHILDREN will disregared the root.in the Alphaa function. Link to comment Share on other sites More sharing options...
Qie Niangao Posted February 3, 2016 Share Posted February 3, 2016 starverse wrote: Link 0 is reserved for "all prims" Nope. Zero is the link number of an unlinked prim. In some functions one can designate all the linked prims with the constant LINK_SET which has a value of -1. Other LINK-related constants: LINK_ALL_OTHERS = -2 LINK_ALL_CHILDREN = -3 LINK_THIS = -4 LINK_ROOT evaluates to 1, but that's only valid on a multiprim linkset. Link to comment Share on other sites More sharing options...
starverse Posted February 3, 2016 Share Posted February 3, 2016 Ugh. i need more coffee. Still, when sequentially making the different prims appear, the OP said he didn't want the root, so the sequence is (using mathematical notation) [2..llGetNumberOfPrims () ] not [0..llGetNumberOfPrims () - 1] which the modulus function was going to get them. k % llGetNumberOfPrims () yields 0 to llGetNumberOfPrims () - 1 OP wanted 2 to llGetNumberOfPrims () to be able to cycle through all the children. I was quibbling with the math, not the program Link to comment Share on other sites More sharing options...
steph Arnott Posted February 3, 2016 Share Posted February 3, 2016 Does not matter if all the prims are counted, as i said the root will be ignored by using what i posted. Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 3, 2016 Share Posted February 3, 2016 Exactly right, Steph. The root prim will always be set to alpha == 0.0 and then immedately to alpha == 1, which is exactly what the OP wants. Doing it that way does switch the root prim off and on again, but in an imperceptible interval. And it gives you a much simpler code. Link to comment Share on other sites More sharing options...
starverse Posted February 3, 2016 Share Posted February 3, 2016 I think I'll stop posting until I learn to read a little better. My mistake. I thought they wanted to skip the root prim. Link to comment Share on other sites More sharing options...
steph Arnott Posted February 3, 2016 Share Posted February 3, 2016 Yes they did which was why i opted for the link child prims solution, nothing wrong witth others, just can not be bothered making the script any more complicated than needed. Maybe im just lazy. Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 3, 2016 Share Posted February 3, 2016 Yup. The OP does want to skip the root prim, which is why the last code I posted uses Steph's suggestion llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES); to set only the child prims to alpha = 0.0 in each time step. The modulus code I wrote switches ALL prims, one at a time, from link ZERO (which does not exist in a linkset) to llGetNumberOfPrims (which is the number of the final prim in the linkset). I deliberately didn't use total_prims = llGetNumberOfPrims() - 1; for that reason. The only bit of sloppiness on my part is addressing link ZERO in that modulus calculation. As a result, there's a 0.15 second hiccup each time the sequence loops past zero. I figured that was acceptable (and almosr imperceptible) collateral damage. 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