shaun Mosswood Posted January 17, 2013 Posted January 17, 2013 Hi everyone,Have just built and installed some roof windows that open and close on touch. I am now looking for a script that will close the windows automatically at night and possibly open them at sunrise if this is possible.Any help much appreciated :)
Xiija Posted January 18, 2013 Posted January 18, 2013 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 ]); }}
shaun Mosswood Posted January 18, 2013 Author Posted January 18, 2013 ah ty for that it will get me started i think
shaun Mosswood Posted January 18, 2013 Author Posted January 18, 2013 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.
Rolig Loon Posted January 18, 2013 Posted January 18, 2013 Study timer events or, better still, spend some time with a few basic tutorials and start to learn how LSL scripts are put together. It's kinda fun, and this particular script you have chosen to write is a great one to begin on. Come back here and post your work if you get stuck. :smileywink:
shaun Mosswood Posted January 18, 2013 Author Posted January 18, 2013 okey dokey i#ll plunge in and have a bash ty for the help
Dora Gustafson Posted January 18, 2013 Posted January 18, 2013 Se sun direction and time of day for what to do about the day being three hours and the night only one hour long :smileysurprised::smileyvery-happy:
Qie Niangao Posted January 18, 2013 Posted January 18, 2013 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.
shaun Mosswood Posted January 18, 2013 Author Posted January 18, 2013 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
Rolig Loon Posted January 18, 2013 Posted January 18, 2013 Be adventurous. Try putting the code snippet from the wiki that Xiija provided into a timer event, as she suggested.
Yingzi Xue Posted January 18, 2013 Posted January 18, 2013 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. } }}
shaun Mosswood Posted January 19, 2013 Author Posted January 19, 2013 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
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