mjrgh / PinballY

A table browser and launcher ("front end") for virtual pinball cabinets.
Other
47 stars 22 forks source link

Add a new javascript event for when Attract Mode is about to select a new game #224

Open mjrgh opened 1 year ago

mjrgh commented 1 year ago

When attract mode is in effect, it automatically switches the wheel to a new game every so often. Currently, Attract Mode chooses the new game to switch to by picking a random number (1 to 10) and advancing that many slots forward on the wheel from the current game. It would be nice to have a way to override the default selection, so that you could use a custom algorithm for selecting the new game. The most general approach I see is to create a new Javascript event that fires when Attract Mode has made its random selection and is about to switch to a new game. The new event ("attractmodeselectgame", maybe) should have a 'game' property in the event object specifying the new game that the built-in random number mechanism selected, and the event handler should be able to override the default selection by changing the 'game' property to the desired game to use instead. Canceling the event should probably prevent the switch from happening at all.