Jump to content

List Timer


RilaVirum
 Share

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

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

Recommended Posts

My Timer is stuck, I'm getting an error on line 61,  why do I keep getting an error on that one line?

 

Line 1... //Cycling between 2 Colors


list Spin = [<0.900, 0.366, 0.905>, <0.526, 0.966, 0.966>];   //Pink and Blue
vector OFFColor = <0.402, 0.446, 0.481>;

integer rezOn = TRUE; 

integer seconds = 5;  //how many seconds between color changes for Spin?


//PRIM POINT LIGHT
integer emitLight = TRUE;

float lightIntensity = 1.0; //intensity of emitted light
float lightRadius = 5.0; //light radius in meters.
float lightFalloff = 1.0; //how rapidly the light dims 

//Control Variables
integer ColorState = 0;
integer ColorChangingTime = 0;
integer TimerSeconds = 0;

integer Hcd (integer x, integer y)  //Highest common divisor
{
    // return the highest common divisor of integers x and y
    if (x == 0)
    {
        return y;
    }
    while (y != 0)
    {
        if (x > y) x = x - y;
        else y = y - x;
    }
    return x;
}

Carousel()
      {
           list params = [];
           integer i;
           integer max = llGetListLength(Spin);
           for (i=0;i<max;i++)
           {
        
                params += [PRIM_COLOR,ALL_SIDES, llList2Vector(Spin, ColorState), 1.0];
                params += [PRIM_POINT_LIGHT, emitLight,llList2Vector(Spin,ColorState),lightIntensity,lightRadius,lightFalloff];
           }
           llSetPrimitiveParams(params);
}
    
default
{
    state_entry()
    {
       
       llSetTimerEvent((float)TimerSeconds);
       
   }
   
    TimerSeconds = Hcd(seconds);      //Highest Common Divisor, I'm getting an Error here
       if (rezOn)
        Carousel();
       
       else state off;
   
}
   
timer()
     
     {
        //the timer has ticked. *something* needs an update! But what? 
        integer update = FALSE;
        
         // Let's find out. Increment the cycle time by the length of the timer cycle.
        ColorChangingTime += TimerSeconds;
       
        // if it is at it's threshold, update its cycle and set the flag for an update.
        if (ColorChangingTime >= seconds)
        {
            update = TRUE;
            ColorChangingTime = 0;
            ColorState++;
        if (ColorState >= llGetListLength(Spin)) ColorState = 0;
        
    }
        // If the cycle passes the threshold 
        // this will update the object spinning number back to 0.
        if (update) Carousel();
}

     touch_start(integer total_number)
     {
                 
     key Avatar = llGetOwner();
     key click = llDetectedKey(0);
     

       if (click == owner)
       {
         
          
          llOwnerSay("On"); 
          Carousel();
}

      else if (click != Avatar)
      {
  
        llSay(0, "Carousel is off");
        state off;

  }

     touch_end(integer num)
     {
        // switch to off state.
        state off;
    }  
    
    on_rez(integer start)
    {
        // always reset on rez.
        llResetScript();
  }
   
}
      
  
state off
        {
              
            state_entry()
            {
              llSetTimerEvent(0.0);
              list params = []; 
              integer i;
              integer max = llGetListLength(Spin);
              for (i=0;i<max;i++)
              {
        
        params += [PRIM_COLOR,ALL_SIDES,OFFColor,1.0];
        params += [PRIM_POINT_LIGHT,FALSE,ZERO_VECTOR,0.0,0.0,0.0];
   }

         llSetPrimitiveParams(Spin);  
          
    }
          
           touch_end(integer num)
    {
       
              state default;
    
    }
    
    on_rez(integer start)
    {
    // always reset on rez.
        llResetScript();
    }
    
}

Edited by RilaVirum
Link to comment
Share on other sites

  • RilaVirum changed the title to List Timer
9 minutes ago, RilaVirum said:


default
{
    state_entry()
    {

       llSetTimerEvent((float)TimerSeconds);

   }

    TimerSeconds = Hcd(seconds);      //Highest Common Divisor, I'm getting an Error here
       if (rezOn)
        Carousel();

       else state off;

}

 

You have code outside of any event. And then you also have code outside of any state.

Keeping your code aligned would help you see these problems.

Edited by Wulfie Reanimator
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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