Author Topic: Display a random image from scraper folder?  (Read 3566 times)

JC10001

  • Newbie
  • *
  • Posts: 9
    • View Profile
Display a random image from scraper folder?
« on: January 17, 2017, 02:58:50 PM »
I would like to display a random image in my layout.

If the emulator is 'mame' - it would pull the image from the scraper -> mame -> snap folder.
If the emulator is 'snes' - it would pull the image from the scraper -> snes -> snap folder.

Or even better (more generic) - if there are games from multiple systems in a list (e.g. fighting games from different systems) - have it pull a random screenshot from one of the games in the list.

Can someone tell me how this is done please?  I tried searching but I could not find anything.  Thank you.
« Last Edit: January 17, 2017, 03:17:06 PM by JC10001 »

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
Re: Display a random image from scraper folder?
« Reply #1 on: January 18, 2017, 03:29:12 AM »
Attractmode does this.

fe.add_artwork( label )

Instead of naming the artwork file to match the label, you just need the folder to match the label, and files in the folder can be called anything.


JC10001

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Display a random image from scraper folder?
« Reply #2 on: January 18, 2017, 01:43:50 PM »
Thanks.  I was able to figure it out.

For anyone else reading this who might have this question...

You want fe.get_artwork(label, rand()) - where label is one of Attract Mode's standard artwork labels ("snap", "wheel", "fanart", etc.).  The second argument (call to the rand() function) will return a random number which gets passed into the  get_artwork function as the index_offset parameter.

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
Re: Display a random image from scraper folder?
« Reply #3 on: January 18, 2017, 03:44:30 PM »
I don't use the rand and get random images.

JC10001

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Display a random image from scraper folder?
« Reply #4 on: January 18, 2017, 07:35:59 PM »
Maybe its something with the layout?  If I don't use rand() it always picks the first game that's selected when I bring up the display.