|
Coro Halasy
Registered User
Join date: 20 Nov 2007
Posts: 1
|
12-04-2007 18:30
I'm not sure if I'm running into key bounce or what, but for reasons unknown, every time I click on the object holding the script, I end up looking at slide4. The first time I click on it, Slide has a starting value of one, which means it should be incrementing to 2 so as to show me slide2. Instead it goes straight to slide4. Anybody have clues as to why?
touch_start(integer total_number) { llSetTimerEvent(10.0); TimeCheck = 1; Slide = Slide + 1; if (Slide = 5) {Slide = 1;} if (Slide = 1) { llSetTexture("slide1", 1);} if (Slide = 2) { llSetTexture("slide2", 1);} if (Slide = 3) { llSetTexture("slide3", 1);} if (Slide = 4) { llSetTexture("slide4", 1);} llMinEventDelay(20.0); }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-04-2007 19:06
integer Slide = 1; integer ON = TRUE;
default{ touch_start(integer total_number){ if(ON){ llSetTimerEvent(10.0); ON = FALSE; } else{ llSetTimerEvent(0.0); ON = TRUE; } } timer(){ if (Slide == 1){ llSetTexture("slide1", 1); } else if (Slide == 2){ llSetTexture("slide2", 1); } else if (Slide == 3){ llSetTexture("slide3", 1); } else if (Slide == 4){ llSetTexture("slide4", 1); Slide = 0; } Slide ++; } }
If you look in the wiki at "timer" then you will also see how to make it so that it shows the texture immediately instead of having to wait the 10 seconds the 1st time.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-04-2007 19:49
integer Slide = 1; integer ON = TRUE;
neTimed() { if (Slide == 1){ llSetTexture("slide1", 1); } else if (Slide == 2){ llSetTexture("slide2", 1); } else if (Slide == 3){ llSetTexture("slide3", 1); } else if (Slide == 4){ llSetTexture("slide4", 1); Slide = 0; } Slide ++; }
default{ touch_start(integer total_number){ if(ON){ neTimed(); llSetTimerEvent(10.0); ON = FALSE; } else{ llSetTimerEvent(0.0); ON = TRUE; } } timer(){ neTimed(); } }
I am not very verbose tonight, rough day today. Ask if there is anything you don't understand here or want clarification on. http://www.cheesefactory.us/lslwm/timer.htmThere is also a more elegant way to do it. Have it build a list of all textures in inventory in the state entry. Then just use Slide as the integer for the place in the list where the texture is to display. EDIT; COOL!!!!! Just now noticed this was your very 1st post!!! Welcome to the scripting forum Coro 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-04-2007 20:39
just so you know, your if statments weren't the problem, it was those pesky assignments in those tests.... slide = 1 //-- changes slide to 1, and so is true(not zero) slide == 1 //-- compares slide to 1, if they are the same it's true when doing comparisons (any test statment) it's food to get into the habit of putting the value first, and the variable second, so that logic errors like this won't compile and you'll get an error notice immediately... 1 = slide //-- will not compile, gives error 1 == slide //-- compares 1 to slide like you intended it also makes it slightly quicker to check visually since the value you are testing for is listed first but using if/else as jesse showed is the better in 99% of cases and since jesse brought it up, recent post regarding texture cycling, with 2 working script versions, (mine uses the method suggested by Jesse above) 
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Ug Llewellyn
Registered User
Join date: 30 Nov 2007
Posts: 4
|
12-04-2007 20:45
From: Coro Halasy I'm not sure if I'm running into key bounce or what, but for reasons unknown, every time I click on the object holding the script, I end up looking at slide4. The first time I click on it, Slide has a starting value of one, which means it should be incrementing to 2 so as to show me slide2. Instead it goes straight to slide4. Anybody have clues as to why?
touch_start(integer total_number) { llSetTimerEvent(10.0); TimeCheck = 1; Slide = Slide + 1; if (Slide = 5) {Slide = 1;} if (Slide = 1) { llSetTexture("slide1", 1);} if (Slide = 2) { llSetTexture("slide2", 1);} if (Slide = 3) { llSetTexture("slide3", 1);} if (Slide = 4) { llSetTexture("slide4", 1);} llMinEventDelay(20.0); } In the script, you try to test the value of Slide by doing "if( Slide = 5 )..." This is wrong. It should be "if( Slide == 5 )". There is a difference between the = operator and the == operator. The = operator SETS something equal to something else. The == operator TESTS for equality. So, what your script was doing was setting Slide to 5, then since 5 is not 0, the condition is true and Slide gets set equal to 1. Slide gets set to each value from 1 to 4 in your "if" statements and ends up showing you slide4 before doing llMinEventDelay(). In short, = does not equal ==.
|