Stacy Aquila Posted March 3, 2011 Share Posted March 3, 2011 I am having trouble with this script below, I would like for it to show/hide 3 sets of prims. The prims have D1, D2 and D3 in there name and I can see the list is being built for each set. The problem is the script seems to not see my input (showd1, hided1 etc) from local and it does not set Alpha with llSetLinkAlpha.the llOwnerSay lines will be removed once the script is working.Any help to get this script running would be great and appreciated ---------------------------------------------------------------------------------------------------------------------------------list PussyPrims;list PrimList;key Owner;list DildoPrims;list AssPrims;init() { integer link; for (link = llGetNumberOfPrims(); link >= 1; --link) { if (llSubStringIndex(llGetLinkName(link), "D1") != -1) { DildoPrims += (list)link; } else if (llSubStringIndex(llGetLinkName(link), "D2") != -1) { PussyPrims += (list)link; } else if (llSubStringIndex(llGetLinkName(link), "D3") != -1) { AssPrims += (list)link; } else if (llSubStringIndex(llGetLinkName(link), "") != -1) { PrimList += (list)link; } }} default{ state_entry() { init(); Owner = llGetOwner(); integer NumLink = llGetNumberOfPrims(); llListen(97, "", NULL_KEY, ""); integer i = 0; do { llOwnerSay("Dildo=" + (string)llList2Integer(DildoPrims,i)); llOwnerSay("**bleep**=" + (string)llList2Integer(PussyPrims,i)); llOwnerSay("Ass=" + (string)llList2Integer(AssPrims,i)); llOwnerSay("PrimList=" + (string)llList2Integer(PrimList,i) ); } while ((++i)<NumLink); } listen(integer channel, string name, key id, string msg){ integer a = 0; integer b = 5; string MSG = llToUpper(msg); while(a++ < b); { if (MSG == "SHOWD1") { llSetLinkAlpha(llList2Integer(DildoPrims,a),1.0, ALL_SIDES); return; } else if (MSG == "HIDED1") { llSetLinkAlpha(llList2Integer(DildoPrims,a),0.0, ALL_SIDES); return; } else if (MSG == "SHOWD2") { llSetLinkAlpha(llList2Integer(PussyPrims,a),1.0, ALL_SIDES); return; } else if (MSG == "HIDED2") { llSetLinkAlpha(llList2Integer(PussyPrims,a),0.0, ALL_SIDES); return; } else if (MSG == "SHOWD3") { llSetLinkAlpha(llList2Integer(AssPrims,a),1.0, ALL_SIDES); return; } else if (MSG == "HIDED3") { llSetLinkAlpha(llList2Integer(AssPrims,a),0.0, ALL_SIDES); return; } } while ((++a)<b); } } Link to comment Share on other sites More sharing options...
Dale Innis Posted March 3, 2011 Share Posted March 3, 2011 The loops are pretty odd; I'm not sure why there are two different "while(a++ < b)" in your listen() event? I can't quite work out what that would do! I would code this as: integer i; string MSG = llToUpper(msg); if (MSG == "SHOWD1") { for (i=0;i<llGetListLength(DildoPrims);i++) llSetLinkAlpha(llList2Integer(DildoPrims,i),1.0,ALL_SIDES); return; } if (MSG == "SHOWD2") { and so on. Something like that anyway! Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 3, 2011 Share Posted March 3, 2011 You have a semicolon at the end of the line that says while(a++ < b); at the top of your listen event. That makes it a null statement, and everything after it is being ignored. Just remove the semicolon. Otherwise, your logic is fine. (You also don't need that same line, repeated at the bottom of the listen event. It's doing nothing there.) Link to comment Share on other sites More sharing options...
Cerise Sorbet Posted March 3, 2011 Share Posted March 3, 2011 Hi, the llListen(97, "", NULL_KEY, ""); should be llListen(97, "", Owner, ""); Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 3, 2011 Share Posted March 3, 2011 Unless you want other people to unlock the chastity belt. :smileyvery-happy: It will work either way. Link to comment Share on other sites More sharing options...
Stacy Aquila Posted March 3, 2011 Author Share Posted March 3, 2011 The "while(a++ < b);" line should be "do" I messed up there but it still compiled. Change number 1 llListen is now set to owner only. change number 2 the first do..... while loop for the llOwnerSay will be removed once the script is working right, leaving just the one remaining. Thanks for the feedback guys, that was quick and very appreciated, now to try the changes :smileyhappy: Link to comment Share on other sites More sharing options...
Stacy Aquila Posted March 3, 2011 Author Share Posted March 3, 2011 Hi Dale, I had my script as you described using for loops but I read that using "do... while" makes for a faster script, I may have to go to this;(posted below) if I have trouble with the "do...while" loop. (the for loop is different from what I had) integer i; string MSG = llToUpper(msg); if (MSG == "SHOWD1") { for (i=0;i<llGetListLength(DildoPrims);i++) llSetLinkAlpha(llList2Integer(DildoPrims,i),1.0,ALL_SIDES); return; } if (MSG == "SHOWD2") { Link to comment Share on other sites More sharing options...
Helium Loon Posted March 3, 2011 Share Posted March 3, 2011 Stacy Aquila wrote: --------------------------------------------------------------------------------------------------------------------------------- list PussyPrims;list PrimList;key Owner;list DildoPrims;list AssPrims;init() { integer link; for (link = llGetNumberOfPrims(); link >= 1; --link) { if (llSubStringIndex(llGetLinkName(link), "D1") != -1) { DildoPrims += (list)link; } else if (llSubStringIndex(llGetLinkName(link), "D2") != -1) { PussyPrims += (list)link; } else if (llSubStringIndex(llGetLinkName(link), "D3") != -1) { AssPrims += (list)link; } else if (llSubStringIndex(llGetLinkName(link), "") != -1) { PrimList += (list)link; } }} default{ state_entry() { init(); Owner = llGetOwner(); integer NumLink = llGetNumberOfPrims(); llListen(97, "", NULL_KEY, ""); integer i = 0; do { llOwnerSay("Dildo=" + (string)llList2Integer(DildoPrims,i)); llOwnerSay("**bleep**=" + (string)llList2Integer(PussyPrims,i)); llOwnerSay("Ass=" + (string)llList2Integer(AssPrims,i)); llOwnerSay("PrimList=" + (string)llList2Integer(PrimList,i) ); } while ((++i)<NumLink); } listen(integer channel, string name, key id, string msg) { integer a = 0; integer b = 5; string MSG = llToUpper(msg); while(a++ < b); // PROBLEM HERE <<<<<<<<< { if (MSG == "SHOWD1") { llSetLinkAlpha(llList2Integer(DildoPrims,a),1.0, ALL_SIDES); return; } else if (MSG == "HIDED1") { llSetLinkAlpha(llList2Integer(DildoPrims,a),0.0, ALL_SIDES); return; } else if (MSG == "SHOWD2") { llSetLinkAlpha(llList2Integer(PussyPrims,a),1.0, ALL_SIDES); return; } else if (MSG == "HIDED2") { llSetLinkAlpha(llList2Integer(PussyPrims,a),0.0, ALL_SIDES); return; } else if (MSG == "SHOWD3") { llSetLinkAlpha(llList2Integer(AssPrims,a),1.0, ALL_SIDES); return; } else if (MSG == "HIDED3") { llSetLinkAlpha(llList2Integer(AssPrims,a),0.0, ALL_SIDES); return; } } while ((++a)<b); } } I've pointed out the main problem..... Your first loop is a null loop. The ';' at the end. And you've got a second loop marker at the end. So your code is only executing once, not multiple times. Perhaps something like this: listen(integer channel, string name, key id, string msg) { integer a = 0; integer b = 5; string MSG = llToUpper(msg); string test = llGetSubString(MSG,0,0); string test2 = llGetSubString(MSG,-1,-1); list templist; float h; if(test == "S") h = 1.0; else h = 0.0; if(test2 == "1") templist = DildoPrims; else if(test2 == "2") templist = PussyPrims; else if(test3 == "3") templist = AssPrims; else return; for(i=0; i<llGetListLength(templist); ++i) llSetLinkAlpha(llList2Integer(templist,a),h,ALL_SIDES); } Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 3, 2011 Share Posted March 3, 2011 Yes, scripting it as a for loop is your slowest option. In this case, though, the time savings is negligble, so it's simply a matter of doing what you find easiest. It should work fine as posted ( as a while loop ), or you could write it as a do .. while loop. Whatever you like. Link to comment Share on other sites More sharing options...
Dale Innis Posted March 3, 2011 Share Posted March 3, 2011 "while" is slightly faster, but as Rolig points out you won't notice it in this case. If there's still a problem I think it will have to do with the fact that you're always going from 0 to 4, instead of looking at the length of the actual list that you're working with (depending on what the listen heard). Link to comment Share on other sites More sharing options...
Stacy Aquila Posted March 3, 2011 Author Share Posted March 3, 2011 thank you Helium, your script had a couple of errors with the declaration of the integers and using a instead of i on the setlinkalpha statement, it was good they where there, giving me a bit more practice in coding, I got it working great now, a nice little script. Thanks for everyone replying and helping, a couple of hours here saved me untold days(and some hair), LOL Link to comment Share on other sites More sharing options...
Helium Loon Posted March 3, 2011 Share Posted March 3, 2011 Sorry about those errors.....I was posting from work, several interruptions, and no chance to proof it. Glad you got it working though. And as many others have already noted, FOR() loops may be marginally slower, but in a simple loop like this, the savings of going with a WHILE() isn't really worth the potential issues with different list lengths. Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted March 3, 2011 Share Posted March 3, 2011 Just to be awkward, I prefer: //for(i=0; i<llGetListLength(templist); ++i)i = llGetListLength(templist);while(i--){llSetLinkAlpha(llList2Integer(templist,i),h,ALL_SIDES);} 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