Light a place
Night Lamp Warm White
A lamp that automatically turns on at night and off during day with warm light.
Goes ina prim
Setup4 to set
Code62 lines
Open toOpen to everyone
What it does
This script makes a prim emit warm white light that turns on automatically when the sun sets and turns off when it rises. It checks the sun's position every 30 seconds to determine day or night.
Settings you can change
4Edit these at the top of the script. Everything works on the defaults · change them only when you need to.
LAMP_COLOR
RGB color vector for the light. Default is warm white (1.0, 0.85, 0.6). Range 0.0 to 1.0 per channel.
·
LAMP_INTENSITY
Brightness of the light. Default 0.6. Range 0.0 to 1.0, higher is brighter.
·
LAMP_RADIUS
How far the light reaches in meters. Default 8.0. Increase for wider coverage.
·
LAMP_FALLOFF
How quickly light dims with distance. Default 0.75. Higher values make light fade faster.
·
// 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();
}
}Copy it, make a new script inworld, paste over what is there and save. Nothing here phones home.