|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
02-02-2009 21:35
I did this script as a flashing light some time ago. It worked fine then, both in the original and in the copies I rezzed later. The "light" flashed endlessly. Suddenly, however, it no longer works. It flashes once, and stops. Can someone please tell me why, and/or tell me what needs to be changed? Probably a simple question for real scripters.  default { state_entry() { llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_LIGHT]); llSetPrimitiveParams( [ PRIM_GLOW, ALL_SIDES, .3 ] ); llSleep (.05); llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_WOOD]); llSetPrimitiveParams( [ PRIM_GLOW, ALL_SIDES, .0 ] );;state default; } }
|
|
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
|
02-02-2009 21:38
Because the bug that caused state_entry to trigger incorrectly upon changing to the current state was fixed. You'd need to move the color flash thing to a timer and set the timer in state_entry.
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
02-02-2009 22:07
Thanks, Faust.
Heh. Figures I would write something that only worked because of a bug. I thought it rather elegant in its simplicity.
By contrast, all the timer scripts I've seen seem extremely complex and convoluted. Can you recommend or demonstrate a simple one that will repeatedly toggle between two states like my original?
I'm afraid I'm not enough of a scripter to get enough info from your first post. I have searched through the forums to try to find what I need, with little luck. And as a result of the bug fix I have a number of products I need to re-script.
|
|
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
|
Nevermind
02-02-2009 22:27
Nevermind. I figured out a solution nearly as elegant. Thanks for your help.
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
02-03-2009 00:53
How about this? default { state_entry() { llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_LIGHT]); llSetPrimitiveParams( [ PRIM_GLOW, ALL_SIDES, .3 ] ); llSleep (.05); llSetPrimitiveParams([PRIM_MATERIAL, PRIM_MATERIAL_WOOD]); llSetPrimitiveParams( [ PRIM_GLOW, ALL_SIDES, .0 ] ); llResetScript(); } }
or maybe this... (this is how I'd do it.) float blinkInterval = 0.5; // how long til the light-state changes (in seconds) vector lightColor = <1.0, 1.0, 1.0>; // rgb color of the LIGHT that is emitted float lightIntensity = 1; // decimal value 0-1 float lightRadius = 10; // decimal value (0-20) float lightFalloff = 0.75; // decimal value 0-2 float glowBrightness = 0.3; // decimal 0-1
integer toggle;
default { state_entry() { llSetTimerEvent(blinkInterval); }
timer() { toggle = !toggle; llSetPrimitiveParams( [ PRIM_POINT_LIGHT , toggle , lightColor , lightIntensity , lightRadius , lightFalloff , PRIM_FULLBRIGHT , ALL_SIDES , toggle , PRIM_GLOW , ALL_SIDES , glowBrightness * toggle ]); } }
Counting on the "material type" to make something a "light" you lose a LOT of configurability. Instead, the code above gives you a lot more control and fine-tuning. (hasn't material-type "light" been depricated?) While it may seem counter-intuitive.. llSleep-Loops take a HUGE amount of script time. (you can put a script into top-scripts in a region, just by making a sleep loop). Timers are generally considered "better" (at least by most people I've ever talked to).. because they allow other events (if any) to trigger between loops.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|