Author Topic: Wrong code  (Read 3131 times)

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Wrong code
« 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.
Nacer a los 15 años Una novela de iOtero

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Wrong code
« Reply #1 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" );
« Last Edit: June 03, 2018, 10:54:30 AM by qqplayer »

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Wrong code
« Reply #2 on: June 03, 2018, 08:07:37 AM »
"Watch & Game"

It may be invalid character, try to use another one

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Wrong code
« Reply #3 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" );

iOtero

  • Sr. Member
  • ****
  • Posts: 414
    • View Profile
Re: Wrong code
« Reply #4 on: June 04, 2018, 11:51:35 AM »
Thanks for your help...  ;D
Nacer a los 15 años Una novela de iOtero

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Wrong code
« Reply #5 on: June 06, 2018, 09:03:46 AM »