How do I make this not random?
|
Lash Xevious
Gooberly
Join date: 8 May 2004
Posts: 1,348
|
10-12-2004 15:03
This is part of a slide show picture. I see where it's making the pictures come out random. How do I change it to make it just go down the contents in the object? // auto change picture integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE, choice); if (name != ""  ; llSetTexture(name, FaceValue);
|
Oneironaut Escher
Tokin White Guy
Join date: 9 Jul 2003
Posts: 390
|
10-12-2004 15:18
Okay, let's see if I can do this. . . // auto change picture integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE, choice); if (name != ""  ; llSetTexture(name, FaceValue); here's my change: // auto change picture integer number = llGetInventoryNumber(INVENTORY_TEXTURE); integer count = 0; while (count <= number) { count++; llSetTexture((llGetInventoryName(INVENTORY_TEXTURE,count)),FaceValue); } llResetScript(); This assumes that the FaceValue was defined as the face you want the texture on (on a cube, 0 - 5). As always, the disclaimer that I'm not a scripter in RL, only in SL, and at that I'm self-taught 
|
Meiyo Sojourner
Barren Land Hater
Join date: 17 Jul 2004
Posts: 144
|
10-12-2004 16:13
From: Lash Xevious This is part of a slide show picture. I see where it's making the pictures come out random. How do I change it to make it just go down the contents in the object? // auto change picture integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE, choice); if (name != ""  ; llSetTexture(name, FaceValue); no biggie *I think* lol... put this line at the top of the code as a global variable: integer picture_index = 0; then replace your code with this: if (picture_index >= llGetInventoryNumber(INVENTORY_TEXTURE)) picture_index = 0; string name = llGetInventoryName(INVENTORY_TEXTURE, picture_index); if (name != "") llSetTexture(name, FaceValue); That should do what you're looking for... I'm assuming this is already inside of a timer event call or something. HTH. -Meiyo
_____________________
I was just pondering the immortal words of Socrates when he said... "I drank what??"
|
Meiyo Sojourner
Barren Land Hater
Join date: 17 Jul 2004
Posts: 144
|
10-12-2004 16:18
From: Oneironaut Escher Okay, let's see if I can do this. . . // auto change picture integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE, choice); if (name != ""  ; llSetTexture(name, FaceValue); here's my change: // auto change picture integer number = llGetInventoryNumber(INVENTORY_TEXTURE); integer count = 0; while (count <= number) { count++; llSetTexture((llGetInventoryName(INVENTORY_TEXTURE,count)),FaceValue); } llResetScript(); This assumes that the FaceValue was defined as the face you want the texture on (on a cube, 0 - 5). As always, the disclaimer that I'm not a scripter in RL, only in SL, and at that I'm self-taught  Just FYI.. assuming the original script was inside of a timer event or something, your code would rotate through all the textures at once without pausing at all each time it is called. Also, the while loop is a little off. Inventory indexes start with 0 so you would want the incrementation to be after the set texture and you would want the conditional statement to be "count < number" not less than or equal... again, because the indexes start with 0 so the biggest index will be number_of_items - 1 -Meiyo
_____________________
I was just pondering the immortal words of Socrates when he said... "I drank what??"
|
Lash Xevious
Gooberly
Join date: 8 May 2004
Posts: 1,348
|
10-12-2004 18:37
Thanks, Meiyo, One. I'll try it again when I log. I'm sure it'll work now. The explanations helped too. 
|
Oneironaut Escher
Tokin White Guy
Join date: 9 Jul 2003
Posts: 390
|
10-13-2004 11:12
After posting, I became curious as to whether it should start with zero - I've never used the inventory functions before, but should have known to assume 0 was the first index. Also, I didn't include a delay (silly me) as I hadn't seen a delay in the original scripting. Should have thought of that as well. Thanks 
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
10-13-2004 11:46
From: someone Also, I didn't include a delay (silly me) as I hadn't seen a delay in the original scripting. Should have thought of that as well. Thanks The original code also did not include a pause. I would have to assume that the pause was coded in another part as was the variable "FaceValue". So don't beat yourself up about that one. =) Even so, it would probably be a good idea to include more than less. 
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
McWheelie Baldwin
Registered User
Join date: 9 Apr 2004
Posts: 154
|
10-13-2004 14:26
You might also want to increment your index, unless you want to see the same picture over and over again.  (Change made in bold red in the code snippet from Meiyo Sojourner's post below.) McW if (picture_index >= llGetInventoryNumber(INVENTORY_TEXTURE)) { picture_index = 0; } string name = llGetInventoryName(INVENTORY_TEXTURE, picture_index); if (name != "") llSetTexture(name, FaceValue); picture_index++;
|
Meiyo Sojourner
Barren Land Hater
Join date: 17 Jul 2004
Posts: 144
|
10-13-2004 15:08
From: McWheelie Baldwin You might also want to increment your index...  *bangs head on keyboard* LMAO thank you for pointing that out McWheelie 
_____________________
I was just pondering the immortal words of Socrates when he said... "I drank what??"
|
Vee Grace
Fashion Guru
Join date: 18 Apr 2004
Posts: 85
|
10-13-2004 15:13
From: Meiyo Sojourner  *bangs head on keyboard* LMAO thank you for pointing that out McWheelie  Don't feel bad. I am constantly doing finger checks on code too. Happens to us all.  McW EDIT: Interesting..... obviously I am not Vee Grace. My sweetie was here for the weekend, and my browser must think I am still her. I sure hope LL gets the forums account bugs ironed out soon. 
|
McWheelie Baldwin
Registered User
Join date: 9 Apr 2004
Posts: 154
|
10-13-2004 15:16
Ahhh much better. I hope you know I didn't mean my original post as an attack, just a light hearted poke from one coder to another. I don't know how many times I have had to hunt down little gotchas like that in the past.  McW
|
Cienna Rand
Inside Joke
Join date: 20 Sep 2003
Posts: 489
|
10-13-2004 15:25
Head over to Luna, my Primcrafters store, pick up the BSD-style licensed PictureBoard script. ;)
_____________________
You can't spell have traffic without FIC. Primcrafters (Mocha 180,90) : Fine eyewear for all avatars SLOPCO (Barcola 180, 180) : Second Life Oil & Petroleum Company Landmarker : Social landmarking software Conversation : Coming soon!
|