Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

texture changer script question

roger Pirandello
Registered User
Join date: 28 Oct 2005
Posts: 59
08-06-2006 16:05
this is probably a very easy question to answer, but since im new to scripting i cant figure it out....im using a free script and one line is "integer choice = (integer)rand;"

this makes the object change textures randomly...
how can i make it go in the order of the textures in the object...apparently "rand" needs to be changed and i cant figure out what it needs to be changed too...

tia
roger
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-06-2006 16:14
From: roger Pirandello
this is probably a very easy question to answer, but since im new to scripting i cant figure it out....im using a free script and one line is "integer choice = (integer)rand;"

this makes the object change textures randomly...
how can i make it go in the order of the textures in the object...apparently "rand" needs to be changed and i cant figure out what it needs to be changed too...

Keep a global variable 'gNextTextureIndex'. Use:
CODE

// Global at top of file
integer gNextTextureIndex = 0;
...
// At the point in code where you want to change textures
gNextTextureIndex %= llGetInventoryNumber(INVENTORY_TEXTURE);
string textureName = llGetInventoryName(INVENTORY_TEXTURE, gNextTextureIndex);
++gNextTextureIndex;
... // (Use textureName as the selected texture here)

(I put the modulo first in case the number of textures changes between calls. You might also put in a test before this to make sure there is at least ONE texture present--or keep track of the number and names of the textures, but this takes some extra event processing and such and the texture is going to have to be loaded anyway, so performance probably isn't that big of an issue here.)
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
08-06-2006 16:21
THere's a thread named "ordered texture changer" few lines below this one that deals exactly with this issue ^^;;

/54/2f/88266/1.html
roger Pirandello
Registered User
Join date: 28 Oct 2005
Posts: 59
08-06-2006 16:53
tyvm you guys, i ushes johannas ...as it was much easier for me to do...worked perferctly....i tried the first one but couldnt get it to work right...would only change the texture once...
anyways thx again:)
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
08-06-2006 19:38
Just so credit goes where it's due, that script is actually Ziggy Puff's ^^;