Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: wrybread on September 24, 2020, 03:32:14 PM
-
I'm giving one of my cabinets some update love, and trying to set a button to choose and launch a random game.
When I last worked on this I saw that AM can choose a random game, but still requires the user to confirm the choice by pressing the "go" button.
Can anyone think of some clever way to map a button to choose and launch a game with a single press?
Ideally it would be a joystick button, since all my buttons use a joystick encoder.
I had a way to do this before using a Python script, and if all else fails I can use that, but it's a bit kludgey since it needs to close Attract Mode and then relaunch AM when the game ends.
-
Look at layouts.md. Create a plugin. Create a signal handler that polls for your input and issues random_game signal.
-
The problem is that the random game signal chooses a game in AM (highlights it in the rom list) but doesn't actually start the game. Last I checked at least, hopefully I'm wrong.
That would be ok if the feature was just for me, but it's a bit complicated for newbies to my cabinet. Much much much cleaner to just press a button and have a random game start.
And I'm on Linux so can't use Auto Hot Key.
-
You don't need autohotkey. I'm on Linux too! :) Send random_game signal and then select signal. Try to work with a plug-in and post here. I'll help you along the way.
-
Would a plug-in let me send those two signals with a single button press?
-
try this >
function random_press(sig)
{
if (sig == "random_game")
{
fe.signal("random_game");
fe.signal("select");
}
return false;
}
fe.add_signal_handler( "random_press" );
-
Thanks again rand0m. For anyone stumbling on this thread, I posted the working plugin here:
http://forum.attractmode.org/index.php?topic=3752.0