Tulinz Posted December 15, 2013 Share Posted December 15, 2013 I'm trying to make a script that changes a texture on one of the faces of a prim once every minute, and after ten minutes, I want the entire script to reset. Can I run two timers ontop of each other like that? Link to comment Share on other sites More sharing options...
Napili Sands Posted December 15, 2013 Share Posted December 15, 2013 You can only have one timer for each state in the script. You'll have to keep track of the time in one timer and set/check a flag when it's time for each event, then reset the flag. 1 Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 15, 2013 Share Posted December 15, 2013 Something like integer counter;integer max = 10; // 10 minutesdefault{ state_entry() { llSetTimerEvent(60.0); //set a timer event every minute. } timer() { ++counter; if ( counter == max ){ llResetScript(); } //do stuff to change texture }} 2 Link to comment Share on other sites More sharing options...
Tulinz Posted December 15, 2013 Author Share Posted December 15, 2013 Cheers mate that seems exacally what I need, Thanks a lot. Link to comment Share on other sites More sharing options...
Tulinz Posted December 15, 2013 Author Share Posted December 15, 2013 I'm having a small issue when I integrated that into my script. The counter value is not reseting when the script resets. So after I reaches max value it starts again above max value and counts up from there Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 15, 2013 Share Posted December 15, 2013 If you have used Innula's LSL snippet as she wrote it, it will automatically reset the counter value to zero when the script resets. When a script resets, ALL variables are reset to their default values. Numerical (integer and float) variables are set to zero. If you have modified the code somehow, the best way to track down your error may be to add a few llOwnerSay statements at strategic places to see what the value of count or other variable is. You will find that you have accidentally changed the logic somehow, so your diagnostic llOwnerSay statements will help you locate the mistake. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted December 15, 2013 Share Posted December 15, 2013 Actually we have more timers than the one associated with the timer eventllSensorRepeat() has an associated timerand llGetTime() has one A script using the latter may look as simple as this: default{ state_entry() { llSetTimerEvent(60.0); //set a timer event every minute. } timer() { //do stuff to change texture if ( llGetTime() >=600.0 ) llResetScript(); }} :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
steph Arnott Posted December 15, 2013 Share Posted December 15, 2013 Click for info and examples on Timers Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 15, 2013 Share Posted December 15, 2013 As Rolig says, my script does reset when the counter hits 10, so something must have changed when you adapted it. Besides putting in the llOwnerSay calls, I would check that you've not typed if (counter = max) (wrong) rather than if (counter == max) (right). That's easily done, and will compile but won't work. Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted December 15, 2013 Share Posted December 15, 2013 Innula Zenovka wrote: As Rolig says, my script does reset when the counter hits 10, so something must have changed when you adapted it. Besides putting in the llOwnerSay calls, I would check that you've not typed if (counter = max) (wrong) rather than if (counter == max) (right). That's easily done, and will compile but won't work. If Tulinz didn't copy/paste, I think this is the most likely error. While we're discussing this, I'll bring up a habit I've developed over years of fixing code written by an idiot (me). I am now leery of testing for equality to bound a counter. Doing so doesn't catch errors resulting from interesting ways I might modify the counter, like incrementing by ten to fast forward, etc. Nor does it catch my failure to initialize the boundary. At the very least, I'd code the termination test as if(counter >= max) which takes a little additional typing effort and may require additional machine instructions if the processor cannot test the zero and carry flags simultaneously, but does allow creative modification of the counter with less worry of breakage. If I were particularly conscientious (I'm capable of that under the right circumstances!), I'd code it as if( (counter<0) || (counter>=max) ). Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now