// Night Lamp - warm white light, automatically on at night, off during day // Drop this script into the prim you want to use as a lamp. // Warm white, gently dimmed vector LAMP_COLOR = <1.0, 0.85, 0.6>; // warm white float LAMP_INTENSITY = 0.6; // not too bright float LAMP_RADIUS = 8.0; // reach in meters float LAMP_FALLOFF = 0.75; integer gIsNight = -1; // -1 = unknown, so first check always applies light_on() { llSetPrimitiveParams([ PRIM_POINT_LIGHT, TRUE, LAMP_COLOR, LAMP_INTENSITY, LAMP_RADIUS, LAMP_FALLOFF, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_GLOW, ALL_SIDES, 0.05 ]); } light_off() { llSetPrimitiveParams([ PRIM_POINT_LIGHT, FALSE, LAMP_COLOR, 0.0, 0.0, 0.0, PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_GLOW, ALL_SIDES, 0.0 ]); } check_time() { // Sun position: z below 0 means the sun is under the horizon = night vector sun = llGetSunDirection(); integer night = (sun.z < 0.0); if (night != gIsNight) { gIsNight = night; if (night) light_on(); else light_off(); } } default { state_entry() { gIsNight = -1; check_time(); llSetTimerEvent(30.0); // check every 30 seconds } timer() { check_time(); } on_rez(integer p) { llResetScript(); } }