DJLoom Posted January 8, 2012 Share Posted January 8, 2012 Simple and easy to use light and glow scripts. They turn on when the sun goes down and turn off when it comes up. Scripts look for sun position every 150 seconds, Can easly be changed. Light Scriptfloat sun_height; vector sun_position; default { state_entry() { llSetTimerEvent(150); } timer() { sun_position = llGetSunDirection(); sun_height = sun_position.z; if(sun_height < 0.0) { llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,<1.0, 1.0, 1.0>,1.0,15,0.750]); } else { llSetPrimitiveParams([PRIM_POINT_LIGHT,FALSE,<1.0, 1.0, 1.0>,1.0,15,0.750]); } } } Glow Scriptfloat sun_height; vector sun_position; default { state_entry() { llSetTimerEvent(150); } timer() { sun_position = llGetSunDirection(); sun_height = sun_position.z; if(sun_height < 0.0) { llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.4]); } else { llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 0.0]); } } } Simple and easy :) 2 1 Link to comment Share on other sites More sharing options...
Morrdecai Posted March 27, 2012 Share Posted March 27, 2012 Can the output light color be set or is it forced white? Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted March 27, 2012 Share Posted March 27, 2012 Morrdecai wrote: Can the output light color be set or is it forced white? In the line... llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,<1.0, 1.0, 1.0>,1.0,15,0.750]); The vector <1.0, 1.0, 1.0> is the color in <R, G, B> form which is white in that example. Change the vector, change the color! 1 Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted March 27, 2012 Share Posted March 27, 2012 Change the vector to change the colour: llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,<1.0, 1.0, 1.0>,1.0,15,0.750]); This will explain: http://wiki.secondlife.com/wiki/Category:LSL_Color [beat me by a minute Madelaine :-)] 1 Link to comment Share on other sites More sharing options...
Oddball Otoole Posted September 28, 2012 Share Posted September 28, 2012 Why not combining both scripts if this is needed for a street lamp or something? :smileyhappy: float sun_height;vector sun_position;default{ state_entry() { llSetTimerEvent(150); } timer() { sun_position = llGetSunDirection(); sun_height = sun_position.z; if(sun_height < 0.0) { llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,<1.0, 1.0, 1.0>,1.0,15,0.750, PRIM_GLOW, ALL_SIDES, 0.4]); } else { llSetPrimitiveParams([PRIM_POINT_LIGHT,FALSE,<1.0, 1.0, 1.0>,1.0,15,0.750, PRIM_GLOW, ALL_SIDES, 0.0]); } }} Or add a random timer to it to simulate a broken flourecent light...:smileysurprised: float glow;float time;//-------------------------------------// Main programdefault{ state_entry() { llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES); state begin; }}//-------------------------------------// Begin statestate begin { state_entry() { glow = (integer) llRound(llFrand(1)); // Random on or off time = (float) llFrand(2); // Random wait time llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0, 1.0, 1.0>, glow, 5.0, 0.5, PRIM_GLOW, ALL_SIDES, glow]); // Set prim light on/of state wait; // Go to the Wait State } }//-------------------------------------// Wait statestate wait { state_entry() { llSetTimerEvent(time); //Wait } timer() { llSetTimerEvent(0.0); //remove the timer state begin; // Go back to the Begin State } } Have fun! 1 Link to comment Share on other sites More sharing options...
ChicByTrinity Posted April 10, 2013 Share Posted April 10, 2013 Why don't they work? I also tried this, and nothing changes, the prim remains unlit and without glow no matter how much I play with the day/night slider. http://inworldz.com/izwiki/index.php/Automatic_Day_Night_Light Link to comment Share on other sites More sharing options...
Sunbleached Posted December 17, 2017 Share Posted December 17, 2017 On 28.09.2012 at 11:13 PM, Oddball Otoole said: Why not combining both scripts if this is needed for a street lamp or something? :smileyhappy: float sun_height;vector sun_position;default{ state_entry() { llSetTimerEvent(150); } timer() { sun_position = llGetSunDirection(); sun_height = sun_position.z; if(sun_height < 0.0) { llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE,<1.0, 1.0, 1.0>,1.0,15,0.750, PRIM_GLOW, ALL_SIDES, 0.4]); } else { llSetPrimitiveParams([PRIM_POINT_LIGHT,FALSE,<1.0, 1.0, 1.0>,1.0,15,0.750, PRIM_GLOW, ALL_SIDES, 0.0]); } }} Or add a random timer to it to simulate a broken flourecent light...:smileysurprised: float glow;float time;//-------------------------------------// Main programdefault{ state_entry() { llSetColor(<1.0, 1.0, 1.0>, ALL_SIDES); state begin; }}//-------------------------------------// Begin statestate begin { state_entry() { glow = (integer) llRound(llFrand(1)); // Random on or off time = (float) llFrand(2); // Random wait time llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0, 1.0, 1.0>, glow, 5.0, 0.5, PRIM_GLOW, ALL_SIDES, glow]); // Set prim light on/of state wait; // Go to the Wait State } }//-------------------------------------// Wait statestate wait { state_entry() { llSetTimerEvent(time); //Wait } timer() { llSetTimerEvent(0.0); //remove the timer state begin; // Go back to the Begin State } } Have fun! Hello! How to make the second script react on sun too? Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 17, 2017 Share Posted December 17, 2017 (edited) 39 minutes ago, Sunbleached said: Hello! How to make the second script react on sun too? Duplicate post. Original is at Please do not post the same question in two places. That makes it difficult for others to see what people have already suggested. Besides, this question does not belong in the script Library. Edited December 17, 2017 by Rolig Loon Link to comment Share on other sites More sharing options...
Sunbleached Posted December 17, 2017 Share Posted December 17, 2017 (edited) 18 minutes ago, Rolig Loon said: Duplicate post. Original is at Please do not post the same question in two places. That makes it difficult for others to see what people have already suggested. Besides, this question does not belong in the script Library. Edited December 17, 2017 by Sunbleached 1 Link to comment Share on other sites More sharing options...
Athayus Quan Posted March 13, 2019 Share Posted March 13, 2019 Thanks for sharing this, question what would I need to add to make it when the glow comes on to cycle or pulse colors at various speeds as well. ? I love the idea of it changing based on time of day or night. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 13, 2019 Share Posted March 13, 2019 That's what the OP was trying to suggest in his other thread Play with that idea. Link to comment Share on other sites More sharing options...
QuietWren Posted December 10, 2019 Share Posted December 10, 2019 (edited) I tried the approach of turning lights on and off on the basis of the sun's Z position but had poor results, so I created a prim and had it report the sun position every 10 seconds: default { state_entry() { llSetTimerEvent(10.0); } timer() { vector sun = llGetSunDirection(); llSetText("Sun X = " + (string)sun.x + "\nSun Y = " + (string)sun.y + "\nSun Z = " + (string)sun.z, <1.0,1.0,0.0>, 1.0); } } What I found is that one "evening" the Sun was still casting shadows when Z was -0.47; the next "morning" the sun resumed casting shadows when it was at Z = -0.87, so the method of using Z < 0 for night seems like it won't work reliably? Some math makes more sense of this, maybe. Z = -.87 and Z = -.47 are when the sun is 60 and 28 degrees below the horizon, respectively. This means the sun was "up" for a total of 60+28+180, or 268 degrees. Probably if I had measured more carefully that would be 270 degrees, or exactly 3/4 of a circle. This makes sense because the sun is "up" for three hours out of four. For some reason there's a 15 degree offset included in this. Edited December 10, 2019 by QuietWren Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2019 Share Posted December 10, 2019 Just as in RL, you can still see sunlight in the sky when the sun is below your horizon. We never see a sharp, instantaneous change from sunlight to total darkness. It's that way by design. The Z component of llGetSunDirection is the sine of the sun's angle above the horizon. I have found experimentally that the period of dawn (or dusk) occurs when Z is within 0.2 > Z > -0.2, or roughly 12 degrees above or below the horizon. BTW, a ten second timer is WAY too fast. The sun does not change its position enough to be perceptible in ten seconds. Try at least a minute. Link to comment Share on other sites More sharing options...
QuietWren Posted December 10, 2019 Share Posted December 10, 2019 (edited) See my simultaneous edited comment above I think this is more about LL's geometry than a horizon effect...and I was using shadows, not twilight. I agree, for any meaningful purpose 10s was far too short, but this was just an ad hoc thing to pin down sunrise/sunset times. Edited December 10, 2019 by QuietWren Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2019 Share Posted December 10, 2019 7 minutes ago, QuietWren said: I think this is more about LL's geometry than a horizon effect...and I was using shadows, not twilight. It amounts to the same thing, in the end. SL is actually a 2D virtual world, not a sphere, so any virtual process that simulates behavior in our 3D world is at best an approximation, and has some unusual side effects. Shadows, for example. Also, don't forget that SL also has a simulated moon, which also casts light (and shadows). In the first version of the SL wiki there was some pseudo-erudite discussion about how daylight behaves in SL. It's all gone now, but from what I recall the bottom line is that Corey and others in the early days were not trying to do things scientifically. Our daylight/nighttime system was a seat of the pants approximation -- enough to fool the natives but not real astronomers. Link to comment Share on other sites More sharing options...
QuietWren Posted December 10, 2019 Share Posted December 10, 2019 (edited) I wish they would bring that discussion back! But to return to the original topic of turning lights on and off-- The black box that is SL day simulation suggests that (without the 15 degree offset) a Z test value of -.71 would give you actual daylight, and maybe use something more negative to capture twilight. I wonder if that 15 degrees offset is a universal constant, or it varies from place to place, or from day to day? And don't start me on the way they do the moon and stars! Edited December 10, 2019 by QuietWren Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 10, 2019 Share Posted December 10, 2019 15 minutes ago, QuietWren said: I wonder if that 15 degrees offset is a universal constant, or it varies from place to place, or from day to day? As far as I know, there are no latitude effects in SL, so the sun behaves the same way everywhere. Of course, it has always been true that people can ignore the real sun but tweaking their personal settings. Now, especially with EEP, more and more landowners are creating local effects that override the standard. All bets are off. 18 minutes ago, QuietWren said: And don't start me on the way they do the moon and stars! I promise. No. Link to comment Share on other sites More sharing options...
KT Kingsley Posted December 10, 2019 Share Posted December 10, 2019 llGetSunDirection is, I think, reporting the EEP sun direction while your viewer is rendering the Windlight settings, and I don't think these are necessarily the same. It may be worth taking a look using the EEP project viewer. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now