Author Topic: Error with conveyor module.  (Read 7793 times)

redhalo

  • Newbie
  • *
  • Posts: 7
    • View Profile
Error with conveyor module.
« on: February 19, 2015, 05:14:32 AM »
Can't figure it out. The below code is almost identical to the example in the conveyor module, but when ran I receive the error "the index 'rawset_index_offset' does not exist"

Code: [Select]
fe.load_module( "conveyor" );

class Card extends ConveyorSlot {
    m_parent = null;
    constructor( parent, text ) {
        m_parent = parent;
        base.constructor( ::fe.add_text( text, 0, 0, 0, 0 ) );
    }

    function on_progress( progress, var ) {
        m_obj.set_rgb( 255, 0, 0 );
        m_obj.width = m_parent.m_width;
        m_obj.height = m_parent.m_height;
        m_obj.x = m_parent.m_x + progress * m_parent.m_x_span;
        m_obj.y = m_parent.m_y + progress * m_parent.m_y_span;
    }
};

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

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

        m_x=x+pad/2; m_y=y+pad/2;

        m_x_span=width;
        m_y_span=0;
        m_width=width/m_objs.len()-pad;
        m_height=height-pad;

        reset_progress();
    }
};

local cards = Cards( "test", 5, 0, 0, fe.layout.width,
  25, 2 );

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: Error with conveyor module.
« Reply #1 on: February 19, 2015, 06:33:42 PM »
yeah I see the "ConveyorSlot" class assumes it will be working on an image and uses the function that is causing your error (which text objects don't have). I'll fix this in the module.

To fix your problem for now, you could override the reset_index_offset() and swap() functions in your Card class.  Try adding the following to the Card class:
Code: [Select]

function reset_index_offset()
{
   set_index_offset( m_base_io );
}

function swap(o)
{
}

I hope that helps!

Edit: missed swap() earlier
« Last Edit: February 20, 2015, 07:45:29 AM by raygun »

redhalo

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Error with conveyor module.
« Reply #2 on: February 20, 2015, 10:46:10 AM »
Thanks for your help. Talk to me about swap() for a sec. Assuming I fill the text with a game title or whatever, with swap() as default in the library it keeps my titles correct but moves the actual items all over the x dimension when changing games. With swap() blank, it keeps the items in place, but messes up the correct m_base_io reference when moving. It's very strange, I feel that this is way more simple than I'm seeing but I just don't seem to get it.

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: Error with conveyor module.
« Reply #3 on: February 21, 2015, 08:38:27 AM »
there is one other setting that in the conveyor module that you need to adjust I suspect.  In your conveyor object, set it's transition_swap_point=1.0, so:

Code: [Select]
my_conveyor <- Conveyor();
my_conveyor.transition_swap_point = 1.0;

I just recently used the conveyor module with text objects in the mala layout loader that will be in the next version.  The code is here:

https://github.com/mickelson/attract/blob/master/config/loader/mala.nut

look at lines 189-220ish for where the conveyor slot is declared and lines 496-499 for the creation of the conveyor itself.

the conveyor does some funny things to try and reduce image reloading.... but I know it can work for texts, hopefully what I've linked helps you get this working!



redhalo

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Error with conveyor module.
« Reply #4 on: February 22, 2015, 06:47:35 AM »
Actually, I found my problem. It works fine with "'[Title]'" style variables, but fe.game_info( Info.Title, index_offset ) doesn't work for me. It has completely different titles in motion than when stationary. I feel it has to do with finding the correct thing to fill the index_offset variable with, but I can't get it working with anything I can think of.

The thing is I'd use the "'[Title]'" style variables, except I want to format the title to remove cruft characters and anything I do to modify that text line just modifies "'[Title]'" as is and not the variable it represents.

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: Error with conveyor module.
« Reply #5 on: February 22, 2015, 12:03:29 PM »
Try using the ConveyorSlot's "base index offset" instead when you call game_info, so:
Code: [Select]
fe.game_info( Info.Title, get_base_index_offset() )

redhalo

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Error with conveyor module.
« Reply #6 on: February 22, 2015, 12:57:43 PM »
Yeah, I've already tried that, doesn't work correctly in either by changing the msg in the constructor or in the on_progress function. I'll just have to work around it for now and maybe a solution will show itself later.