Sherrade Stirling
Along for the ride
Join date: 28 Aug 2004
Posts: 149
|
12-09-2005 12:34
I'm working with this simple texture-switcher by touch script. My question is, how can I change it so that the textures go in a certain order (number, alpha, whatever) instead of random? Pardon my scripting ignorance. I did look all over the wiki and forums but couldn't find something I understood lol. Thx. SCRIPT: { touch_start(integer total_number) { integer number = llGetInventoryNumber(INVENTORY_TEXTURE); float rand = llFrand(number); integer choice = (integer)rand; string name = llGetInventoryName(INVENTORY_TEXTURE, choice); if (name != ""  llSetTexture(name, ALL_SIDES); } }
_____________________
Visit TRINKETS Nothing over L$99 in the shop! Most way under 
|
Oasis Perun
Registered User
Join date: 2 Oct 2005
Posts: 128
|
12-09-2005 12:59
integer choice = 1; //initialize this to one(not sure if this is best but it works)
touch_start(integer total_number) {
string name = llGetInventoryName(INVENTORY_TEXTURE, (choice - 1)); if (name != "") { llSetTexture(name, ALL_SIDES); }
else { choice = 0;//if its a blank name start back at start }
choice++;//next touch will be this texture # if you are counting from 1 the compiler counts from zero } } this should work... however my same disclaimer applies..(im at work with no way to debug or test).. if anybody knows a more efficient way or sees a bug please fix it for me. Tested and working.. paste it into your favorite state and let the texture switching begin 
|