|
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
|
12-23-2006 08:24
I am trying to only show the textures that do not start with "IgnoreMe" in this example below. Right now it just does nothing if the current texture starts with "IgnoreMe". How can I get it to initially ignore those textures and just show the others? integer numTextures = llGetInventoryNumber(INVENTORY_TEXTURE); if (currTexture < numTextures) { // If we have more textures. ++currTexture; // Go to the next one. } else { currTexture = 0; // Go to the beginning of the list. } string textureName = llGetInventoryName(INVENTORY_TEXTURE, currTexture); if (textureName != "" && llGetSubString(textureName, 0, 7) != "IgnoreMe") { setLinkTexture(LINK_SET, textureName, ALL_SIDES); llSetText((string)textureName,<1,0,0>,.5); }else { //Do nothing } }
|
|
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
|
12-23-2006 09:53
I see two things to correct... one is the way you count to next currTexture, and the other is not skipping past textures with IgnoreMe in them. // code was if (currTexture < numTextures) // should be if (currTexture < (numTextures - 1)) and here's a version that should do what you want. // revised to find the next non-ignored texture integer numTextures = llGetInventoryNumber(INVENTORY_TEXTURE); if (currTexture < numTextures - 1) { // If we have more textures. ++currTexture; // Go to the next one. } else { currTexture = 0; // Go to the beginning of the list. } string textureName = llGetInventoryName(INVENTORY_TEXTURE, currTexture); // skip textures starting with "IgnoreMe" integer tries = numTextures; // fail-safe for no non-ignore while ((tries > 0) && (llSubStringIndex(textureName, "IgnoreMe") == 0)) { llOwnerSay("skipping " + textureName); // for debug purposes --tries; ++currTexture; // skip this one if (currTexture >= numTextures) currTexture = 0; textureName = llGetInventoryName(INVENTORY_TEXTURE, currTexture); } if (tries > 0) // did not bail out, so valid name found { setLinkTexture(LINK_SET, textureName, ALL_SIDES); llSetText((string)textureName,<1,0,0>,.5); } else { llOwnerSay("no textures found."); // for debug purposes } I added a few messages so you can see what it's doing, you can remove those of course.
|