Jump to content

Night sensor


shaun Mosswood
 Share

You are about to reply to a thread that has been inactive for 3671 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

from the lsl wiki..

http://wiki.secondlife.com/wiki/LlGetSunDirection

 

you could add this to a script with a timer?

 

This can be used to quickly determine whether it is day or night (in shortened SL days) as the script runs: if the returned vector's Z element is positive, then the sun is above the horizon.

integer lightsOn = -1;//not TRUE or FALSE CheckSun(){    vector sun = llGetSunDirection();    integer turnLightsOn = (sun.z < 0);    if(turnLightsOn != lightsOn)    {        lightsOn = turnLightsOn;        llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES, lightsOn ]);    }}
Link to comment
Share on other sites

 
ok lol this didnt get me started, im not proficient in scripting and im of the impression that to do what i want, eg, get the roof window to open when the sun comes up and close when it goes down, is beyond my capabilities.
 
 I understand i need a script to check for the sun position etc but have no idea how to link this to the window open/close script, already in the prim, or indeed a timer script.
Link to comment
Share on other sites

If I understand the situation here, you may not have source for the script that opens and closes the windows on touch. If that's the case, you'll first have to figure out how they open and close and emulate that in your own script, then add the sun direction and timer logic to make it happen at night.

Depending on the geometry of the window prims, there are many different ways a script might open and close them, so it's kind of difficult to help with that, short of examining them in detail.

Link to comment
Share on other sites

 
I have built the roof window and installed it complete with a script to open and close the window when you touchh it.
 
All works well and i have it set up for opening speed and how far it opens, all this is spot on but what i want to do now is add to the window the ability for it to open and close automatically so open when the sun comes up and then close when the sun goes down.
 
I believe the open and close on touch script can stay so as to be able to override the auto feature and im of the understanding that this all has something to do with a sensor script that detects the position of the sun.
 
My problem is that i dont know how to put all this together :)
 
Link to comment
Share on other sites

llGetSunDirection(); will return a vector of x, y and z.  All you're concerned about is whether the sun is above or below the horizon and to what degree.  You'll want to set up a timer.  I suggest 60 seconds, which will make it accurate to a minute.

 

default{    state_entry()    {        // Add this to your state_entry() event so it starts a timer when         // your script starts.  The timer immediately starts counting to         // 60 seconds.  After 60 seconds the timer event (below) triggers.          // The timer continues to count 60 seconds indefinitely and        // trigger the timer event unless you llSetTimerEvent(0);                llSetTimerEvent(60);      }    // Timer event which triggers after counting every x seconds.    timer()    {        // Use a local vector since we don't care to store the sun's         // direction.  Once the timer event runs the memory used by the         // temp vector is emptied.                vector temp = llGetSunDirection(); // Get sun direction x, y, z                // Check z, which is sun's vertical position; 0 = at horizon.        // If you want you can get fancy and add more if statements to         // open door gradually as sun moves but you will have to have a         // faster timer because the sun moves quicker than 60 seconds         // per tick.                if (temp.z < 0)        {                       // Less than zero means sun is below horizon.           // Add code here to open window.                   } else        {                       // Greater than zero means sun is above horizon.           // Add code here to close window.                   }    }}

 

Link to comment
Share on other sites

Wow !! thanks very much for that :)  I have had a go myself but now ive seen your explanation im pretty sure I know where I am going wrong.  I think with some experimentation I can get this .

I am intending to sell these roof windows on the market place so I would not want to upset you by using your info and guide without your permission.  Myabe I should put your name as credit in the header of the script and make it no copy ?

Please get back to me on this as I dont want to tread on any toes and thanks again :)

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3671 days.

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
 Share

×
×
  • Create New...