Attract-Mode Support > Scripting

System List possible?

<< < (2/3) > >>

dukpoki:

--- Quote from: kent79 on May 15, 2018, 10:24:29 AM ---You may refer my theme. It is similar you want  :)
http://forum.attractmode.org/index.php?topic=2211.0

--- End quote ---

Hey man, thank you so much!  Btw, that's a very nice theme.  So I've been messing with it for the past hour and I can't seem to isolate the list to a certain number of systems (instead of showing them all).  You're code is too advanced for me. :P

I've done some more digging with much trial and error and i've come up with something like this (example):


--- Code: ---function on_transition( ttype, var, ttime )
{

local display1 = fe.displays[fe.list.display_index - 1].name; //previous display
local display2 = fe.displays[fe.list.display_index].name; //current display
local display3 = fe.displays[fe.list.display_index + 1].name; //next display

local sys_text1 = fe.add_text (display1, 100, 200, 600, 100); //note: can use sys_text#'s to fe.add_image if I wanted images instead of text
local sys_text2 = fe.add_text (display2, 500, 200, 600, 100);
local sys_text3 = fe.add_text (display3, 1000, 200, 600, 100);

}
fe.add_transition_callback( this, "on_transition" );
--- End code ---

The only problem i'm facing with this is the transition callback isn't working properly.  Every time I switch back and forth between displays, the previous text does not disappear and instead overlaps each other.  Any ideas on this?

qqplayer:

--- Quote from: kent79 on May 15, 2018, 04:28:21 PM ---I have revised the script to make a sample. You may try it.  :)


--- Code: ---local ui_filters=[];
local ui_underline=[];

        // System   
        for ( local i = 0; i < fe.displays.len(); i++ ) {
            local filter = fe.displays[i];
            local shortname = filter.name.toupper();
            local offset = 55 * i;
           
            switch(filter.name) {
                //prefer known abbreviations
                case "Sega Model 2":
                    shortname = "SM2";
                    break;
                case "Sega Model 3":
                    shortname = "SM3";
                    break;
case "Sega Naomi":
                    shortname = "NAO";
                    break;

                //grab the first three letters as the short name
                default:
if (shortname.len() > 3)
shortname = shortname.slice(0, 3);
                    break;
            }
           
            local newfilt = fe.add_text(shortname, -18 + offset, 1, 73, 18);
            newfilt.set_rgb( 240, 240, 240 );

            local underline = fe.add_image("white.png", -18 + offset, 20, 60, 3);
            underline.set_rgb( 240, 0, 0 );
    underline.visible = false ;

            if (i == fe.list.display_index)
                underline.visible = true;
            ui_filters.push(newfilt);
ui_underline.push(underline);

        }

fe.add_transition_callback( this, "on_transition" );

function on_transition( ttype, var, ttime )
{

//Update filter highlight
                for ( local i = 0; i < ui_underline.len(); i++ )

                    ui_underline[i].visible = false;
                    ui_underline[fe.list.display_index].visible = true;

}
--- End code ---

--- End quote ---

Thank you so much , is working :)

I`m with @dukpoki , is any way to set maybe only three previous and three next...
Not the whole thing...

@dukpoki , I think you need to add something like this:


--- Code: ---function on_transition( ttype, var, ttime ) {
 switch ( ttype ) {
  case Transition.StartLayout:
  case Transition.ToNewList:
local display1 = fe.displays[fe.list.display_index - 1].name; //previous display
local display2 = fe.displays[fe.list.display_index].name; //current display
local display3 = fe.displays[fe.list.display_index + 1].name; //next display

local sys_text1 = fe.add_text (display1, 100, 200, 600, 100); //note: can use sys_text#'s to fe.add_image if I wanted images instead of text
local sys_text2 = fe.add_text (display2, 500, 200, 600, 100);
local sys_text3 = fe.add_text (display3, 1000, 200, 600, 100);
  break;
  }
 return false;
}

fe.add_transition_callback( "on_transition" );
--- End code ---

kent79:
The best System List is combine with Conveyor module. But sorry I don't know how to write a script in this moment . Need some time for study. ArcadeBliss is a Expert. He should know how to do  :P

dukpoki:
Got it working.


--- Code: ---
 ::OBJECTS <- {

system1= fe.add_text("",47,48,300,40)
system2= fe.add_text("",47,90,300,40)
system3= fe.add_text("",47,132,300,40)
system4= fe.add_text("",47,174,300,40)
system5= fe.add_text("",47,222,300,40)

}

function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
case Transition.StartLayout:
case Transition.ToNewSelection:
case Transition.FromOldSelection:
            switch ( fe.list.name )
            {             
case "Atomiswave":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name; //previous display
        local display3 = fe.displays[fe.list.display_index].name; //current display
        local display4 = fe.displays[fe.list.display_index + 1].name; //next display
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
OBJECTS.frame.file_name = "images/frames/Default_frame.png";
break;

        case "Dreamcast":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name; //previous display
        local display3 = fe.displays[fe.list.display_index].name; //current display
        local display4 = fe.displays[fe.list.display_index + 1].name; //next display
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
        OBJECTS.frame.file_name = "images/frames/Default_frame.png";

        break;
            }
break;
    }

}

fe.add_transition_callback("transition_callback" );


--- End code ---

Make sure to add all your systems/displays by adding more "cases".

EDIT:  Has problems with the beginning and the end of the list.  I'm not sure how to make it loop.  Will research.

EDIT 2:  Found a very rough workaround.  You have to subtract or add the total index number which you can use fe.displays.len() to find.
So for example if you have a list of 10 systems then for the first system you need to -2, -1, 0, +1, +2 but make sure the first two formulas you are adding 10 to it.  So the formula will be (-2 + 10) and (-1 + 10).  That way the end result is the number that is at the end of the list 8 and 9 respectively and not negative numbers.  Because you the display index will never be a negative number.

For example i am doing this:

--- Code: ---                local displaytotal = fe.displays.len();

//excerpt code below
case "Atomiswave":
local display1 = fe.displays[fe.list.display_index - 2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1 + displaytotal].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
break;

--- End code ---

qqplayer:
@dukpoki Is gaving me an error , "the index -2 does not exist"

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version