Author Topic: Fading out wheels except the selected one  (Read 196 times)

BadFurDay

  • Full Member
  • ***
  • Posts: 63
    • View Profile
Fading out wheels except the selected one
« on: July 13, 2017, 04:50:40 PM »
Hi there,

I have a theme where the wheels fade out, I'm wondering if anyone would know how to code it so the wheel you're currently on doesn't fare out while the rest do.

Thanks for any help, the code below is what is in the layout.nut for the wheels to fade:

//Wheel fading
if ( wheel_fade_ms > 0 )
{
   function wheel_fade_transition( ttype, var, ttime )
   {
      if ( ttype == Transition.ToNewSelection || ttype == Transition.ToNewList )
            first_tick = -1;
   }
   fe.add_transition_callback( "wheel_fade_transition" );
   
   function wheel_alpha( ttime )
   {
      if (first_tick == -1)
         stop_fading = false;

      if ( !stop_fading )
      {
         local elapsed = 0;
         if (first_tick > 0)
            elapsed = ttime - first_tick;

         local count = conveyor.m_objs.len();

         for (local i=0; i < count; i++)
         {
            if ( elapsed > wheel_fade_ms)
               conveyor.m_objs.alpha = 0;
            else
               //uses hardcoded default alpha values does not use wheel_a
               //4 = middle one -> full alpha others use 80
               if (i == 4)
                  conveyor.m_objs.alpha = (255 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
               else
                  conveyor.m_objs.alpha = (80 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;
         }

         if ( elapsed > wheel_fade_ms)
         {
            //So we don't keep doing the loop above when all values have 0 alpha
            stop_fading = true;
         }
      
        if (first_tick == -1)
            first_tick = ttime;
      }
   }
   fe.add_ticks_callback( "wheel_alpha" );
}

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Fading out wheels except the selected one
« Reply #1 on: July 14, 2017, 05:31:49 AM »
I think if you comment this line

conveyor.m_objs.alpha = (255 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;

to comment a line in squirrel is like java or c, with double slash (//)

BadFurDay

  • Full Member
  • ***
  • Posts: 63
    • View Profile
Re: Fading out wheels except the selected one
« Reply #2 on: July 16, 2017, 04:50:43 PM »
I think if you comment this line

conveyor.m_objs.alpha = (255 * (wheel_fade_ms - elapsed)) / wheel_fade_ms;

to comment a line in squirrel is like java or c, with double slash (//)

Thanks for the suggestion but I'm afraid it didn't work.