Author Topic: Help me understand the conveyor module  (Read 12453 times)

ArcadeBliss

  • Sr. Member
  • ****
  • Posts: 195
    • View Profile
Help me understand the conveyor module
« on: September 21, 2015, 10:42:14 AM »
I am animating three slots and I want the objects to rest in exact x coordinates and can't figure this out.  Studying the orbit layout hasn't  helped.  Trial and error is resulting in more error than success.  Can anyway give me a tip? 

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 880
    • View Profile
Re: Help me understand the conveyor module
« Reply #1 on: September 21, 2015, 03:41:27 PM »
ArcadeB-

If you just need to animate 3 slots of artwork you can use the SimpleArtstrip that extends on the conveyor module. Just change the bottom part of the script "local my_strip = SimpleArtStrip()" to whatever you like. You will essentially define the type of artwork and the width and height of it as well as the padding between the art. Tip, I would use small increments otherwise dramatic results can be expected. Also, I believe the example that I provided will create a vertical wheel on the right side. This is a good base to start with. To create a horizontal wheel or art you would essentially swap the values of width height.  For example changing the value of fe.layout.width/3.5 to 1.5 and vice versa for height change the art to horizontal. See bottom readme for a better explanation.

fe.load_module( "conveyor" );

class SimpleArtStrip extends Conveyor
{
   m_x=0; m_y=0; m_width=0; m_height=0; m_x_span=0; m_y_span=0;

   constructor( artwork_label, num_objs, x, y, width, height, pad=0 )
   {
      base.constructor();
      local my_list = [];
      for ( local i=0; i<num_objs; i++ )
         my_list.push( SimpleArtStripSlot(this,artwork_label) );
      set_slots( my_list );

      m_x=x+pad/2; m_y=y+pad/2;
      if ( width < height )
      {
         m_x_span=0;
         m_y_span=height;
         m_width=width-pad;
         m_height=height/m_objs.len()-pad;
      }
      else
      {
         m_x_span=width;
         m_y_span=0;
         m_width=width/m_objs.len()-pad;
         m_height=height-pad;
      }

      reset_progress();
   }
};

local my_strip = SimpleArtStrip( "wheel", 5, flw*0.625, flh*0.08, fe.layout.width/3.5, fe.layout.height/1.2, 5 );

Here is a more complete readme on it by Raygun.

///////////////////////////////////////////////////
//
// SimpleArtStrip class
//
// Create a simple artwork strip that smoothly animates a transition when
// the selection changes
//
// SimpleArtStrip( artwork_label,num_objs,x,y,width,height,pad=0 )
//
// Parameters:
//
//   artwork_label - the label of the artwork to show in the strip (i.e. "snap")
//   num_objs - the number of artwork objects to show in the strip
//   x - the x position of the top left corner of the strip
//   y - the y position of the top left corner of the strip
//   width - the width of the entire strip
//   height - the height of the entire strip
//   pad - the amount of padding to insert between each object in the strip
//        (default value of 0)
//
// If height>width, you will get a vertical strip.  Otherwise the strip will
//  be horizontal.
//
// Usage example.  The following code creates a strip of 5 snap artworks across
// the top of the screen:
//
//    local my_strip = SimpleArtStrip( "snap", 5, 0, 0,
//             fe.layout.width, fe.layout.height/3, 2 );
//
///////////////////////////////////////////////////



ArcadeBliss

  • Sr. Member
  • ****
  • Posts: 195
    • View Profile
Re: Help me understand the conveyor module
« Reply #2 on: September 25, 2015, 12:32:57 PM »
Hi O-Man  ;)

Thanks for the insight. To accomplish what I am trying to achieve, I can not use the simpleartstrip. Let me be a little more precise. In your robo layout, you are setting the x coordinates for the wheel using this array:

Code: [Select]
local wheel_x = [ flx*0.80, flx*0.795, flx*0.756, flx*0.725, flx*0.70, flx*0.68, flx*0.64, flx*0.68, flx*0.70, flx*0.725, flx*0.756, flx*0.76, ];
This is the line that used the progress "p" to move to the next x coordinates:
 
Code: [Select]
m_obj.x = wheel_x[slot] + p * ( wheel_x[slot+1] - wheel_x[slot] );
Are the values in the array "wheel_x" giving absolute resting values for displaying the wheel's items? Are the amount of items on the wheel in relation to the conveyour setup?  If not, is this even possible and if yes, what needs to change.

My code uses a similar setup just with Y being a fix value.

Thanks,

AB

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 880
    • View Profile
Re: Help me understand the conveyor module
« Reply #3 on: September 25, 2015, 04:21:18 PM »
ArcadeB-

ArcadeB-

Yes, the x coordinates are essentially where each slot place holder will be for the art.  It took be awhile to wrap my head around this as well, so I understand the confusion. Anyway, if you look at the example below you will notice the wheel_x coordinates for each slot are positioned to the right of the select slot position which is flx*0.63. Then by using the wheel_y slot coordinates we can create a carousel or stair case effect from that flx*0.63 slot position. In this scenario, the Y slot coordinates are a little more tricky. Because, the first two Y coordinates are being drawn off screen. Hence, the negative values. So, basically fly*0.0 will be the top slot or wheel to be drawn on screen, then fly*0.105 would be the second and etc. Since, I am only drawing 10 slots on the screen, I set local num_arts  to 10. This may help you understand why there are 10 arts being displayed though the code shows coordinates for 12. If you need more technical info on the conveyor module itself feel free to send Raygun an email as he helped me with getting this accomplished. I hoped this helped. This is hard stuff to explain.  :)

ArcadeBliss

  • Sr. Member
  • ****
  • Posts: 195
    • View Profile
Re: Help me understand the conveyor module
« Reply #4 on: October 07, 2015, 10:24:45 AM »
I figured it out. I was over thinking how this worked. I had original changed the orbit layout to only have 4 coordinates in the array thinking the conveyour module would automatically smoothout the transition between the x stops.

After changing the spin speed to a snails pace, I was able to find the error. I now use 12 slots in the array to ensure the smooth motion.

Thanks for your help.

cools

  • Full Member
  • ***
  • Posts: 83
  • Arcade Otaku Sysadmin
    • View Profile
    • Arcade Otaku
Re: Help me understand the conveyor module
« Reply #5 on: April 27, 2020, 09:13:09 AM »
Is there any way of having the conveyor spin infinitely when a key is held, rather than coming to a stop at the end of a list?