|
MoonpaiSun Ra
Registered User
Join date: 13 Dec 2006
Posts: 2
|
09-30-2007 21:23
I'm trying to create a real strobe light using prim point light. I figure the best way to toggle quickly between on and off is by using a timer event set to .1 seconds. Every .1 second, the script should check if the prim's light is set to fully on or fully off. If off, it should switch to on etc...
To do this, I will tell the prim to also switch between 0.0 Alpha and 1.0 Alpha, and use llGetAlpha to return whether the last state was "on" or "off" and to swtich accordingly.
In the wiki, I can't find any instructions on how to use an llGet command in if/then statements. So far I can only find llGet(whatever) used in llSay.
How do you use llGetAlpha (or llGetColor, Pos, whatever) in an "if" statement.
That is, if Alpha = 0.0, llSetAlpha to 1.0, and if Alpha = 1.0, llSetAlpha to 0.0.
Thanks a lot!
MoonpaiSun Ra.
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
09-30-2007 21:30
if (llGetAlpha(ALL_SIDES) == 0.0) ... else if (llGetAlpha(ALL_SIDES) == 1.0) ...
or you could use a switch
integer switch
if (switch) { llSetAlpha(ALL_SIDES,0); switch =0; }
else { llSetAlpha(ALL_SIDES, 1); switch = 1; }
|
|
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
|
09-30-2007 21:52
You don't even need an if:
llSetAlpha( ALL_SIDES, !(integer)llGetAlpha(ALL_SIDES) );
or with a variable:
llSetAlpha( ALL_SIDES, switch = !switch );
ex:
integer s;default{state_entry(){for(;1;)llSetAlpha(-1,s=!s);}}
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
10-01-2007 00:30
you can also add a glow effect that flickers using and extra hollowed prim sized slightly larger and only textured on the inside
llSetAlpha( ALL_SIDES, !llGetAlpha( ALL_SIDES ) * 0.1 );
will work for partial gradients (just made a "magic apple" with this yesterday)
|
|
MoonpaiSun Ra
Registered User
Join date: 13 Dec 2006
Posts: 2
|
thanks!
10-01-2007 21:37
I'd never even heard of the "switch" command! I was suprised there wasn't something like that-- turns out I just hadn't found it.
Thanks very much!
-Moonpaisun Ra
|
|
Malachi Petunia
Gentle Miscreant
Join date: 21 Sep 2003
Posts: 3,414
|
10-01-2007 22:37
I think you misread. There is no switch/case in LSL, you were seeing an integer named "switch" being used as a boolean above.
Regardless, an alpha change every 100ms is a relatively heavyweight action (thus laggish). A particle emitter with the right parameters is far more efficient.
IM me in game if you want me to drop the strobe script I just made on you.
|