Author Topic: Possible to make a screensaver that cycles through games? (solved, sort of)  (Read 519 times)

qqplayer

  • Sr. Member
  • ****
  • Posts: 211
    • View Profile
Well with a whole lot of duct tape I got everything working. My cabinet swaps to a random game every 5 minutes if no one is playing it, which has officially gotten us out of our rut of playing the same few games over and over. And it makes our MAME cabinet a lot more interesting in general, since every time I walk past there's some new oddball artifact of the 80s or 90s playing on it. If you don't mind a heinous pun, it's a game changer (oof, sorry about that).

It would be so nice if this was natively possible in Attract Mode! Unfortunately I don't where to start for adding the functionality there though. If any AM devs are interested, I'm glad to help however I can though.


An outline of how I got it working:

- I made an Attract Mode screensaver.nut that simply launches my Python script after X minutes of inactivity

- my Python script then launches a new game after every 5 minutes (configurable) of inactivity, and is smart enough to reset it's inactivity counter even during game play (something that Attract Mode currently can't do, as far as I can tell). So it keeps launching random games whenever no one is using the cabinet. And someone can start playing that game any time. But if someone presses the exit button, they're returned to Attract Mode so they can choose specific games manually.

- and the cycle repeats: Attract Mode will then relaunch my script after X minutes of inactivity.


A couple of nice features:

- the script starts either via a screensaver.nut after X minutes, or manually via a "Random" button on my cabinet (the Random button executes an AM plugin that launches the script)

- currently it picks a random ROM from the roms directory, but it could easily be adapted to choose a random entry from a specific Attract Mode romlist.

- it detects when a ROM doesn't launch properly and adds it to a list of bad ROMs that it won't use in the future. Also handy for finding and fixing bad ROMs.

- the script can run independently of Attract Mode, but it's nice to also give the user the ability to choose their own games manually, which Attract Mode does so beautifully. So the user is returned to Attract Mode when they press the Exit button on the cabinet.

- it works with my ServoStik to change the joystick between 4 and 8 way as needed



The duct tape part:

- when my Python script launches it has to kill Attract Mode, or AM will keep responding to keystokes in the background. That's a big issue since for example when exiting a game from my script AM will simultaneously launch a game, which is a pretty big conflict. Solved by simply killing AM.

- when my Python script exits, it then relaunches Attract Mode, so the player can manually choose games again.


I'm glad to share it if there's interest, but I made it for Linux so I'd have to make a few mods if someone wanted to use it on Windows.

And if any Attract Mode devs have interest in implementing this natively in AM, I'd be glad to help. I think this is what would be required:

- have AM listen for keystrokes and/or joystick action while a ROM is playing. Possibly solvable by a secondary script that sends an activity notice to AM whenever there's activity (maybe by sending dummy keypresses to the AM interface?).

- or if AM was remote controllable, an external script could simply tell Attract Mode to launch new games at will. For example if I could run "attract_mode_cli mame/dkong" or maybe send a command through a webserver or a network socket, then an external script could handle the screensaver part but still play nice with AM.

Maybe someone can improve a solution if you post the code...
I think you need to use the github channel if you want the main developer to answer.