Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help with photo album script

Ares Baroque
Registered User
Join date: 11 Aug 2007
Posts: 8
07-28-2008 09:23
Hi,
I am making a texture changer script which could be used as a book or a photo album.
I am wanting to add a if statement which will stop my counting variable once it hits page 1. thanks in advance.

integer count = 1;

default
{
touch_start(integer total_number) //when touched
//make variable to detect link name
{
string button = llGetLinkName(llDetectedLinkNumber(0));


if (button == "next";) //if the object named next is touched.
{
count ++;
llSetTexture((string)count,1); //make color blue
llSetText((string)count,<0,1,0>,1.0);
}

if (button == "back";) //if the back object is clicked
{
count --;
llSetTexture((string)count,1); //make the color blue
llSetText((string)count,<0,1,0>,1.0);

}


if (count == 1)
{

/// when my book goes backward to page 1, I want the pages to stop turning back.
}

}
}
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
07-28-2008 10:00
From: Ares Baroque
I am wanting to add a if statement which will stop my counting variable once it hits page 1.
Include it inside the "if( button == "back" )" clause:

CODE
        if (button == "back") //if the back object is clicked
{
if( count == 1 )
return;

count --;
llSetTexture((string)count,1); //make the color blue
llSetText((string)count,<0,1,0>,1.0);

}


BTW, just a note about efficiency: Since the "button" variable can't possibly ever be both "next" and "back", it's better to make that "else if( button == "back" )". That way, the second if won't even be evaluated if the first one was true.
Ares Baroque
Registered User
Join date: 11 Aug 2007
Posts: 8
07-28-2008 10:51
thank you Deanna