Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: Dal1980 on December 09, 2016, 03:03:57 AM

Title: Squirrel setting conveyor() (wheel) fall-back image logos
Post by: Dal1980 on December 09, 2016, 03:03:57 AM
Hi Guys

I'm using the following additional code below to check for object file_name (i.e. no wheel logo). Works great except the missing wheel logo fallbacks only pop-on after I move the wheel. The constructor method is triggered then only the on_progress method is activated at the point where the wheel moves so I need a way to loop through and check file_name properties at the point of load.

Code: [Select]
     class WheelEntry extends ConveyorSlot {
     
          constructor() {
               base.constructor( ::fe.add_artwork( myConfig["orbit_art"] ));
               //base.constructor( ::fe.add_image( "parts/no-logo.png" ) ); //this loads but doesn't then place the wheel art
     }
         
          function on_progress( progress, var ) {
               local p = progress / 0.1;
               local slot = p.tointeger();
               p -= slot;
               slot++;

               if ( slot < 0 ) slot=0;
               if ( slot >= 10 ) slot=10;

/* ADDITIONAL */
               if(m_obj.file_name == ""){
                    m_obj.file_name = "parts/no-logo.png";
                    m_obj.preserve_aspect_ratio = true;
               }
/* ADDITIONAL */

               m_obj.x = wheel_x[slot] + p * ( wheel_x[slot+1] - wheel_x[slot] );
               m_obj.y = wheel_y[slot] + p * ( wheel_y[slot+1] - wheel_y[slot] );
               m_obj.width = wheel_w[slot] + p * ( wheel_w[slot+1] - wheel_w[slot] );
               m_obj.height = wheel_h[slot] + p * ( wheel_h[slot+1] - wheel_h[slot] );
               m_obj.rotation = wheel_r[slot] + p * ( wheel_r[slot+1] - wheel_r[slot] );
               m_obj.alpha = wheel_a[slot] + p * ( wheel_a[slot+1] - wheel_a[slot] );


          }
     };

Ideally a solution should not touch the main conveyor.nut file (which I've not been able to successfully locate actually: is it this one "/usr/local/share/attract/modules/conveyor.nut" ?).

So close but not close enough.
Many thanks
Dal
Title: Re: Squirrel setting conveyor() (wheel) fall-back image logos
Post by: Dal1980 on December 12, 2016, 10:34:48 AM
#BUMP#

Anyone got any suggestions for activating the on_progress in WheelEntry?
Title: Re: Squirrel setting conveyor() (wheel) fall-back image logos
Post by: Dal1980 on June 21, 2018, 06:25:38 AM
I wouldn't normally bump a topic this old but I just tried to google the same question and came across my own post!  :o ;D.

Can someone please point me in the right direction

Code: [Select]
     class WheelEntry extends ConveyorSlot {
     
          constructor() {
               base.constructor( ::fe.add_artwork( myConfig["orbit_art"] ));
     }
         
          function on_progress( progress, var ) {
               local p = progress / 0.1;
               local slot = p.tointeger();
               p -= slot;
               slot++;

               if ( slot < 0 ) slot=0;
               if ( slot >= 10 ) slot=10;

/* ADDITIONAL */
               if(m_obj.file_name == ""){
                    m_obj.file_name = "parts/no-logo.png";
                    m_obj.preserve_aspect_ratio = true;
               }
/* ADDITIONAL */

               m_obj.x = wheel_x[slot] + p * ( wheel_x[slot+1] - wheel_x[slot] );
               m_obj.y = wheel_y[slot] + p * ( wheel_y[slot+1] - wheel_y[slot] );
               m_obj.width = wheel_w[slot] + p * ( wheel_w[slot+1] - wheel_w[slot] );
               m_obj.height = wheel_h[slot] + p * ( wheel_h[slot+1] - wheel_h[slot] );
               m_obj.rotation = wheel_r[slot] + p * ( wheel_r[slot+1] - wheel_r[slot] );
               m_obj.alpha = wheel_a[slot] + p * ( wheel_a[slot+1] - wheel_a[slot] );


          }
     };


This works but only after the conveyor has moved.