Jump to content

Light Script syntax error


RilaVirum
 Share

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

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

Recommended Posts

Hello, need help please! I'm getting a syntax error in my script, this is the line:

 float lightIntensity = 1.0;   //Syntax Error 

    

 

 

//Living Room Table that flashes colors

//(Rewriting this script from 2 objects to one)


list TableLinkNumber = [1];

// Set the color of the table when it is OFF
vector TableOFF = <0.434, 0.434, 0.434>;

//Make the list of colors I'm picking two colors for right now
list sequenceOfColors = [<0.163, 0.845, 0.022>,<0.760, 0.039, 0.021>];

//How many seconds between color changes? Whole Numbers only for this one
integer InSECONDS = 5;

// GLOW - how much glow in the object?
float GlowNumber = 1.0;

// Light emissions if enabled the object will emit light when on
integer LightOn = TRUE
float lightIntensity = 1.0;   //Syntax Error
float lightRadius = 5.0;
float lightFallOff = 1.0;

// on-rez state
integer rezON = TRUE; //Set TRUE to rez "on" set FALSE to rez "off"

//  ==== END OF CONFIG ====

// These are integers to control the time and the state of the tables changing colors
integer timerSeconds = 0;
integer colorState = 0;
integer colorTime = 0;

//Functions go here

//I need help with the FUNCTIONS part of this script! I'm not sure if this section is needed for a one color flashing object.
//This FUNCTION section seems to be set up for more than one object 

        DoColorCycle()
        {
            //This is where the magic happens!
            //Update all the colors and other parameters
            list params = [];
             integer i;
             integer max = llGetListLength(TableLinkNumber); 
             for (i=0;i<max;i++)
              {
    
                   
                    
                    params += [PRIM_COLOR,ALL_SIDES,1.0];
                    params += [PRIM_GLOW,ALL_SIDES,GlowNumber];
                    params += [PRIM_POINT_LIGHT,ALL_SIDES,LightOn,llList2Vector(sequenceOfColors,colorState),lightIntensity,lightRadius,lightFalloff];
                    
                    //Note params += [PRIM_LINK_TARGET] Removed 
            
              }
        
             llSetLinkPrimitiveParamsFast(0,params);
            
}
        
default
{
    // the default state is used ONLY for validating our config and setup.
    state_entry() 
    {
        //ok, we've just been rezzed or reset. Setup time!
        //scan the linkset looking for "Object1 on the description box, make sure what you write in the description box is detected.
        integer n = llDetectedKey(0);
        if (n == 1)
        {
            //Object Detected
            llOwnerSay("Link Number Detected");
            return;
        }
        integer i;
        for (i=1;i<=n;i++)
        
        //DESCRIPTION BOX SET-UP
        
        {
     
            string description = llList2String(llGetPrimitiveParams(i,[PRIM_DESC]),0);
            if (description == "Object1")
            {
                TableLinkNumber += [i];
        
        }
        //ok, now the list is connected to the description section, we need to make sure the Object Link Number is Valid and Unique
        TableLinkNumber = SortUniqueLinks(TableLinkNumber);
      
        // Recheck this here
        if (!(llGetListLength(TableLinkNumber)))
        {
            //oops! The List length is zero
            llOwnerSay(Object1 is not detected Fix this and re-rez or click me to reset the script.");
            return;
        }
        // Now set up the timer parameter. The most efficient cycle length is the highest common divisor of the cycle times
        // for both color cycles. Obviously if either is prime and not a divisor of the other, this will end up being 1, but 
        // if we can be more efficient than triggering a timer event every second, why not do it?
        //
        // first, though, let's make sure the timer intervals are valid!
        if (!(InSECONDS >= 1))
        {
            //oops! no they aint valid. Timer intervals must be a positive integer.
            llOwnerSay("The timer intervals must be a positive whole number Fix this and either re-rez or touch me to reset the script.");
            return;
        }
        timerSeconds = Hcd(InSECONDS);
        // All validations have now passed and setup is complete. We're good to go!
        // set either running or off state depending on the "rezOn" config setting.
        if (rezOn) state running;
        else state off;
    }
    
    touch_start(integer num)
    {
        // we'll only stay in the default state if there was a config error, so touching means reset the script.
        llResetScript();
    }
    
    on_rez(integer start)
    {
        // always reset on rez.
        llResetScript();
    }
}

state running 
{
    // this state runs the timer, progressing the cycle state forward every time the timer ticks.
    // a touch in this state will halt this process and switch to the off state.
    
    state_entry()
    {
        // set up the timer
        llSetTimerEvent((float)timerSeconds);
        //don't update the numbers, just pick up where we left off
        DoColorCycle();
    }
    
    timer()
    {
        //the timer has ticked. *something* needs an update! But what?
        integer update1 = FALSE;
        integer update2 = FALSE;
        // Let's find out. Increment both cycles time by the length of the timer cycle.
        colorTime += timerSeconds;
        //I deleted color2time here
        // if either one is at its threshold, update its cycle and set the flag for an update.
        if (colorTime >= InSeconds)
        {
            update1 =TRUE;
            colorTime = 0;
            colorState++;
            if (colorState >= llGetListLength(sequenceOfColors)) colorState = 0;
        }
       
        // If all we needed to do was update the times, we're done. But if either cycle passed its threshold we 
        // must update the object params.
        if (update1) DoColorCycle();
    }
    
    // for "functional" touches, it's always better to detect the end of the mouse-click so we use 
    // a touch_end event instead of a touch_start
    touch_end(integer num)
    {
        // switch to off state.
        state off;
    }
    
    on_rez(integer start)
    {
        // always reset on rez.
        llResetScript();
    }
}

state off 
{
    // this state is real simple. it kills the timer, sets the "off" color with no glow or light emission
    // then waits for a touch to start running again.
    
    state_entry()
    {
        llSetTimerEvent(0.0);
        list params = [];
        integer i;
        integer max = llGetListLength(TableLinkedNumber);
        for (i=0;i<max;i++)
        {
            //PRIM_LINK_TARGET removed, I'm not sure if I need it
            params += [PRIM_COLOR,ALL_SIDES,TableOFF,1.0];
            params += [PRIM_GLOW,ALL_SIDES,0.0];
            params += [PRIM_POINT_LIGHT,FALSE,ZERO_VECTOR,0.0,0.0,0.0];
        }
       
        llSetLinkPrimitiveParamsFast(0,params);
    }
    
    // for "functional" touches, it's always better to detect the end of the mouse-click so we use 
    // a touch_end event instead of a touch_start
    touch_end(integer num)
    {
        // switch to running state.
        state running;
    }
    
    on_rez(integer start)
    {
        // always reset on rez.
        llResetScript();
    }
}

Edited by RilaVirum
Link to comment
Share on other sites

Go back and double check the { brackets in that event.  You are missing one.   Errors like this are very common but are also very easy to detect.  As you script, indent carefully so that you know where each scope within the script begins and ends.  Keep track of matching brackets and parentheses.  Watch for missing semicolons.  We all have lapses of attention from time to time, but errors like that are easy to spot and fix.  It might help to use a script editor like Sublime Text that watches for those things automatically.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

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