Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: JC10001 on January 17, 2017, 02:58:50 PM

Title: Display a random image from scraper folder?
Post by: JC10001 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.
Title: Re: Display a random image from scraper folder?
Post by: bionictoothpick 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.

Title: Re: Display a random image from scraper folder?
Post by: JC10001 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.
Title: Re: Display a random image from scraper folder?
Post by: bionictoothpick on January 18, 2017, 03:44:30 PM
I don't use the rand and get random images.
Title: Re: Display a random image from scraper folder?
Post by: JC10001 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.