Jump to content
  • 0

Automatic night/day on/off lighting?


CarneyInc Mint
 Share

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

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

Question

So I've been attempting to produce a script that will cause objects to light up when it is night, and turn off when it is day. I figure it would be an easy matter to modify the given script on the SL Wiki to do this:

integer lightsOn = -1;//not TRUE or FALSE

CheckSun()
{
    vector sun = llGetSunDirection();
    integer turnLightsOn = (sun.z < 0);
    if(turnLightsOn != lightsOn)
    {
        lightsOn = turnLightsOn;
        llSetPrimitiveParams();




However, it has been causing me some trouble. I have some basic object-oriented program experience, but not very much, and am currently struggling to correctly modify this script. As of right now, what I am trying to make work is below, where I am simply attempting to make sure it can differentiate between night and day, but I can't even get it to compile correctly.

integer lightsOn = -1;

default
{
    touch_start(integer total_number)
    {
        vector sun = llGetSunDirection();
        integer turnLightsOn = (integer)(sun.z < 0);
        if(turnLightsOn != lightsOn)
        {
            lightsOn = turnLightsOn;
            llSay(0,turnLightsOn);
            llSetPrimitiveParams();
        }
    }
}

Please advise! either on making the script I am attempting work, or even if someone knows of a/how to do the script I am looking for!! Thanks!!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The only compile error I get for your script is in the llSay() function.  The second parameter must be a string, but you are passing it an integer.  LSL does not, in general, support automatic casting between types.  Amend the line to llSay(0, (string) turnLightsOn); and you should be fine.

ETA: In future you may be happier hanging with the rest of us geeks: Second Life Forums > Scripting

  • Like 1
Link to comment
Share on other sites

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