Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: iOtero on June 02, 2018, 02:37:59 AM

Title: Wrong code
Post by: iOtero on June 02, 2018, 02:37:59 AM
In my layout this code works perfectly:

Code: [Select]

// Hand Held
local artwork = fe.add_image("hh/[Emulator].png", flx*0.52, fly*0.4,  flw*0.260, flh*0.462);
artwork.preserve_aspect_ratio = true;

// Boxart
local box = FadeArt("boxart", flx*0.52, fly*0.6,  flw*0.130, flh*0.231);
box.preserve_aspect_ratio = true;
box.trigger = Transition.EndNavigation;


But if I add these modifications ("Watch & Game" is an emulator), it does not work:

Code: [Select]

local myboxart = "[Emulator]";

if (myboxart == "Watch & Game")
{
// Boxart
local box = FadeArt("boxart", flx*0.52, fly*0.6,  flw*0.130, flh*0.231);
box.preserve_aspect_ratio = true;
box.trigger = Transition.EndNavigation;
}
else
{
// Hand Held
local artwork = fe.add_image("hh/[Emulator].png", flx*0.52, fly*0.4,  flw*0.260, flh*0.462);
artwork.preserve_aspect_ratio = true;
}


Could someone tell me what I'm doing wrong?

Thanks in advance.
Title: Re: Wrong code
Post by: qqplayer on June 03, 2018, 04:21:06 AM
Not tested, I think you need a function with transition callbacks.

I made this for system info

http://forum.attractmode.org/index.php?topic=2258.0

Code: [Select]
//box_system

function box_system(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
        case Transition.StartLayout:
//case Transition.ToNewSelection:
//case Transition.FromOldSelection:
    switch ( fe.list.name )
            {             
case "Watch & Game":
                local artwork_image = fe.add_image("hh/[Emulator].png", flx*0.52, fly*0.4,  flw*0.260, flh*0.462);
                artwork_image.preserve_aspect_ratio = true;
    break;
        }
    }

}

fe.add_transition_callback("box_system" );
Title: Re: Wrong code
Post by: kent79 on June 03, 2018, 08:07:37 AM
"Watch & Game"

It may be invalid character, try to use another one
Title: Re: Wrong code
Post by: qqplayer on June 03, 2018, 10:56:41 AM
I've writted two "" , but maybe this will work even with "&"

Quote
ocal a = "I'm a wonderful string\n"
// has a newline at the end of the string
local x = @"I'm a verbatim string\n"
// the \n is copied in the string same as \\n in a regular string "I'm a verbatim string\n"

So:

Code: [Select]
//box_system
local x = @"Watch & Game"

function box_system(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
        case Transition.StartLayout:
//case Transition.ToNewSelection:
//case Transition.FromOldSelection:
    switch ( fe.list.name )
            {             
case "x":
                local artwork_image = fe.add_image("hh/[Emulator].png", flx*0.52, fly*0.4,  flw*0.260, flh*0.462);
                artwork_image.preserve_aspect_ratio = true;
    break;
        }
    }

}

fe.add_transition_callback("box_system" );
Title: Re: Wrong code
Post by: iOtero on June 04, 2018, 11:51:35 AM
Thanks for your help...  ;D
Title: Re: Wrong code
Post by: qqplayer on June 06, 2018, 09:03:46 AM
This should be another solution

http://forum.attractmode.org/index.php?topic=192.0