Difference between revisions of "User:Toady Nakamura/Two States Light"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) (added LSL Tip) |
m (base tag) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Using two states can sometimes be an elegant solution to on/off. | Using two states can sometimes be an elegant solution to on/off. | ||
*Original framework 04-16-08 by | *Original framework 04-16-08 by Toady Nakamura | ||
*Light call modified from Simon Kline's classes "Scripting from Scratch" | *Light call modified from Simon Kline's classes "Scripting from Scratch" | ||
<source lang="lsl2"> | |||
< | vector color = <1.0, 1.0, 1.0>; // Use to change the color of the light | ||
float intensity = 1.0; // Use to change the intensity of the light, from 0 up to 1 | |||
float radius = 10.0; // Use to change the Radius of the light, from 0 up to 20 | |||
float falloff = 0.75; // Use to set the falloff of the light, from 0 up to 2 | |||
default | |||
{ | |||
touch_start(integer total_number) | |||
{ | |||
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, intensity, radius, falloff]); | |||
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); | |||
state unlit; | |||
} | |||
} | |||
state unlit | |||
{ | |||
touch_start(integer total_number) | |||
{ | |||
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, color, intensity, radius, falloff]); | |||
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); | |||
state default; | |||
} | |||
on_rez(integer param) | |||
{ | |||
llResetScript(); | |||
} | |||
} | |||
</source> | |||
== Another way to do the same thing == | |||
After this script was posted an "expert" scriptor came along and changed it. Since their new version has no explanatory notes, and no longer matches the in world student notes, I have reverted the original version and appended their version here. It does exactly the same thing, but is considered by the person changing these pages to be "better." | |||
<source lang="lsl2"> | |||
vector color = <1.0, 1.0, 1.0>; | vector color = <1.0, 1.0, 1.0>; | ||
float intensity = 1.000;// from 0.0 up to 1.0 | float intensity = 1.000;// from 0.0 up to 1.0 | ||
float radius = 10.000;// from 0.0 up to 20.0 | float radius = 10.000;// from 0.0 up to 20.0 | ||
float falloff = 0.750;// from 0.0 up to 2.0 | float falloff = 0.750;// from 0.0 up to 2.0 | ||
default | default | ||
{ | { | ||
Line 18: | Line 54: | ||
llResetScript(); | llResetScript(); | ||
} | } | ||
touch_start(integer num_detected) | touch_start(integer num_detected) | ||
{ | { | ||
Line 24: | Line 60: | ||
[PRIM_POINT_LIGHT, TRUE, color, intensity, radius, falloff, | [PRIM_POINT_LIGHT, TRUE, color, intensity, radius, falloff, | ||
PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); | PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); | ||
state lightOn; | state lightOn; | ||
} | } | ||
} | } | ||
state lightOn | state lightOn | ||
{ | { | ||
Line 35: | Line 71: | ||
llResetScript(); | llResetScript(); | ||
} | } | ||
touch_start(integer num_detected) | touch_start(integer num_detected) | ||
{ | { | ||
Line 41: | Line 77: | ||
[PRIM_POINT_LIGHT, FALSE, color, intensity, radius, falloff, | [PRIM_POINT_LIGHT, FALSE, color, intensity, radius, falloff, | ||
PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); | PRIM_FULLBRIGHT, ALL_SIDES, FALSE]); | ||
state default; | state default; | ||
} | } | ||
} | } | ||
</ | |||
</source> | |||
Visit my LSL wiki page for my library of simple scripts ! [[User:Toady Nakamura|Toady Nakamura]] |
Latest revision as of 17:40, 28 July 2015
Using two states can sometimes be an elegant solution to on/off.
- Original framework 04-16-08 by Toady Nakamura
- Light call modified from Simon Kline's classes "Scripting from Scratch"
vector color = <1.0, 1.0, 1.0>; // Use to change the color of the light
float intensity = 1.0; // Use to change the intensity of the light, from 0 up to 1
float radius = 10.0; // Use to change the Radius of the light, from 0 up to 20
float falloff = 0.75; // Use to set the falloff of the light, from 0 up to 2
default
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, intensity, radius, falloff]);
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
state unlit;
}
}
state unlit
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, color, intensity, radius, falloff]);
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
state default;
}
on_rez(integer param)
{
llResetScript();
}
}
Another way to do the same thing
After this script was posted an "expert" scriptor came along and changed it. Since their new version has no explanatory notes, and no longer matches the in world student notes, I have reverted the original version and appended their version here. It does exactly the same thing, but is considered by the person changing these pages to be "better."
vector color = <1.0, 1.0, 1.0>;
float intensity = 1.000;// from 0.0 up to 1.0
float radius = 10.000;// from 0.0 up to 20.0
float falloff = 0.750;// from 0.0 up to 2.0
default
{
on_rez(integer start_param)
{
llResetScript();
}
touch_start(integer num_detected)
{
llSetLinkPrimitiveParamsFast(LINK_THIS,
[PRIM_POINT_LIGHT, TRUE, color, intensity, radius, falloff,
PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
state lightOn;
}
}
state lightOn
{
on_rez(integer start_param)
{
llResetScript();
}
touch_start(integer num_detected)
{
llSetLinkPrimitiveParamsFast(LINK_THIS,
[PRIM_POINT_LIGHT, FALSE, color, intensity, radius, falloff,
PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
state default;
}
}
Visit my LSL wiki page for my library of simple scripts ! Toady Nakamura