Author Topic: Merge string variables.  (Read 5205 times)

De_Cadanz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Merge string variables.
« on: September 30, 2015, 11:37:20 PM »
How I can obtain current emulator name (name of CFG file) and merge it with text? I want to add ".png" extension to emulator name.
Something like this (i know, it's wrong code):

Code: [Select]
local emu = fe.game_info( Info.Emulator )
emu = emu+'.png'

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Merge string variables.
« Reply #1 on: October 01, 2015, 02:53:24 PM »
Actually that is correct, but you will want to use it in a transition callback, something like:

Code: [Select]
local emuImage = fe.add_image("attract.png", 0, 0, 100, 100);

function transition( ttype, var, transition_time )
{
   if ( ttype == Transition.StartLayout || ttype == Transition.ToNewSelection || ttype == Transition.ToNewList )
   {
      local current = fe.game_info(Info.Emulator);
      emuImage.file_name = current + ".png";
   }
   return false;
}

FYI though - if you compile a recent build, I believe you can use the "magic tokens" directly in the filename you pass, so you can just do an fe.add_image("systems/[Emulator].png"); and it should update although I haven't tested that yet.

De_Cadanz

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Merge string variables.
« Reply #2 on: October 02, 2015, 03:02:11 AM »
You miss fe.add_transition_callback("transition");
Thanks, you helps me a lot!