Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

I need help with indexed textures

Cris Poliak
Registered User
Join date: 14 Apr 2008
Posts: 27
02-08-2010 14:46
Hi there, I can't get this code to work properly. I've got 2 prims (left & right) that change the textures stored inside the right one which contains the main script.
It means, if we click on the left one it will turn the page back and if the right one is clicked it'll turn to the next 2 pictures.
It works fine, except when it arrives to the last picture or first one.. I want it to be able to ignore clicks on the proper button if we've reached the max/min index.

How can I do it?

Here's the code snippet...
CODE

link_message(integer sender_num, integer num, string msg, key id)
{
if (numberTextures)
{
if (("NEXT" == msg) || ("PREV" == msg))
{
if ("NEXT" == msg )
{
//*************** PROBLEM STARTS HERE ***************
if ( currentTexture < numberTextures-1 )
{
currentTexture+=2;
}
}
else
{ //substract one
if ( currentTexture < numberTextures-1 && currentTexture!=0 )
{
currentTexture-=2;
}
else
{
currentTexture=0;
}
}
currentTexture = (currentTexture + numberTextures) % numberTextures;
llSetTexture( llGetInventoryName( INVENTORY_TEXTURE, currentTexture ), 0);

llMessageLinked(LINK_SET,1,(string)llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE, currentTexture-3)),NULL_KEY);
//******************************
}
}
}//link_message

Thank you =)
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
02-09-2010 06:37
Hi Cris, not sure exactly what you want to do (don't get the 2 textures stuff then the -3 afterwards)...however here is a simple tip : add or substract first then do the checks:

currentTexture += 2;
if (currentTexture > numberTextures-2) currentTexture = numberTextures -2 ;
// or whatever is your limit

currentTexture -= 2;
if (currentTexture < 0) currentTexture = 0;

Try this and let us now
_____________________