Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer STATE_AlwaysOff = 0;
- integer STATE_AlwaysOn = 1;
- integer STATE_OnAfterDark = 2;
- integer iOn = FALSE;
- integer iNight = FALSE;
- integer iState = STATE_OnAfterDark;
- autoSwitch()
- {
- vector vecSun = llGetSunDirection();
- iNight = (vecSun.z < 0);
- if (iState == STATE_AlwaysOff) {
- iOn = FALSE;
- } else if (iState == STATE_AlwaysOn) {
- iOn = TRUE;
- } else {
- iOn = iNight;
- }
- if (iOn) {
- llSetPrimitiveParams ([ PRIM_POINT_LIGHT, iOn, <1.0, 1.0, 1.0>, 1.0, 8.0, 0.5,
- PRIM_GLOW, ALL_SIDES, 0.25 ]);
- } else {
- llSetPrimitiveParams ([ PRIM_POINT_LIGHT, iOn, <1.0, 1.0, 1.0>, 0.0, 0.0, 0.0,
- PRIM_GLOW, ALL_SIDES, 0.0 ]);
- }
- }
- initialize()
- {
- iOn = FALSE;
- iState = STATE_OnAfterDark;
- autoSwitch();
- llSetTimerEvent(300);
- }
- default
- {
- on_rez(integer start_param)
- {
- initialize();
- }
- state_entry()
- {
- llSetText("NightLight",<1,0,0>,1);
- initialize();
- }
- timer()
- {
- autoSwitch();
- }
- touch_start(integer total_number)
- {
- if (iState == STATE_AlwaysOff) {
- iState = STATE_AlwaysOn;
- llWhisper(0, "Lamp is now always on.");
- } else if (iState == STATE_AlwaysOn) {
- iState = STATE_OnAfterDark;
- llWhisper(0, "Lamp will now turn itself on after dark.");
- } else {
- iState = STATE_AlwaysOff;
- llWhisper(0, "Lamp is now always off.");
- }
- autoSwitch();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement