Jump to content

Day & Night object changing?


Loki Eliot
 Share

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

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

Recommended Posts

Is anyone able to point me in any direction with regards to accoplising the following efect with a script.

I have an object i want to appear during the day, then at night replaced with a different object by perhaps turning one object invisible and the other object not invisible?

Can anyone advise on best practice to achieve this and point me in a direction for possible script examples please?

Link to comment
Share on other sites

standard method is to check the llSunDirection on a timer...  if the z value is less than than 0, and your "sun is up" variable is true, flip the variable. otherwise z is higher, and if your sun variable is false, flip it.... any time you flip it you can also take an action, like sending a command, rezzing a box etc.

test = llGetSunDirection();if (test.z < 0.0){
if (isDay){ isDay = FALSE; //-- do night stuff
}}else if (!isDay){ isDay = TRUE; //-- do day stuff}

 ETA:
got sloppy, fixed

  • Like 1
Link to comment
Share on other sites

Here's a script which switches a light on at dusk, off at dawn.

// Script to switch light on at dusk, off at dawninteger daytime (){    vector SunDirection;    SunDirection = llGetSunDirection();    if (SunDirection.z>0.0) {        return (FALSE);    } else {        return (TRUE);    }}switchlight (integer onoff) // function to switch light on or off{    llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,onoff]);    llSetPrimitiveParams([PRIM_POINT_LIGHT,onoff,<1.0,1.0,1.0>,1.0,15.0,0.5]);}default                 {    on_rez (integer start_param)    {        llResetScript();    }         state_entry()    {        if (daytime()==TRUE) {             state extinguished;        } else {            state illuminated;        }    } }    state illuminated     // switch light off at dawn{    state_entry()    {        switchlight(TRUE);        llSetTimerEvent(300.0);    }    timer ()              {        if (daytime()==TRUE) {             llSetTimerEvent(0.0);            state extinguished;        }    }}state extinguished     // switch light on at dusk{    state_entry()    {        switchlight(FALSE);        llSetTimerEvent(300.0);    }    timer ()    {        if (daytime()==FALSE) {             llSetTimerEvent(0.0);            state illuminated;        }    }}

 

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Thank you very much! Here is the LSL script I made. It's not exactly the one Void posted, but it seems to work.

 

default {    state_entry() {        llSetTimerEvent(600);    }    timer() {        vector sun = llGetSunDirection();            if(sun.z > 0) {            llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, "paste UUID here"]);            }            else {            llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, "paste UUID here"]);            }    }}

 

Link to comment
Share on other sites

  • 1 year later...

Hello,

 

I found this thread while loking for a script.  I am looking to turn off the light fluction of my lights and light textures at night.  This script does not seem to work in my objects.  Can you help?

 

A

Link to comment
Share on other sites

If you are a scripter and are trying to find your way around a sticky spot in a script you are writing, you have come to the right place.  That's what this forum is for.  However, if you are looking for a free script (or even one to buy), there are several script libraries here, in the LSL wiki, and in world.  You can also shop in Marketplace or do a Google search for script repositories elsewhere.  If you are hoping to have someone write a script for you, you should post in the InWorld Employment forum. 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3709 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...