Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Mayki07 on August 31, 2018, 09:19:10 AM
-
Could someone write a script or plugin for Linux (Raspberry Pi) that would export the name of the selected game or system to a separate txt file?
I would need it to display the information or marquee on the additional LED Matrix panel.
https://github.com/hzeller/rpi-rgb-led-matrix
If you can help me, I'll be very grateful ...
-
Alas, I can't help you directly, but if you don't get answers here soon, you could ask in a suitable forum for your Linux variant, e.g. the Gaming (https://www.raspberrypi.org/forums/viewforum.php?f=78) and Raspbian (https://www.raspberrypi.org/forums/viewforum.php?f=66) sections of the official Raspberry Pi forum, or in the official Retropie forum (https://retropie.org.uk/forum/), if you're using that.
-
Thank you for trying to help.
In the Retropie forum I have already asked, it seems like no one knows how to do it. It's only by using the runcommand-onstart script, but it will select the game name or marquee until the game starts, not when choosing what I want. I'm not a programmer, but I thought it could somehow go through Attractmode and layout.nut and the fe.add or another command ... :'(
I'm building the Arcade Cabinet and I wanted to use the glossy LCD Matrix screen to display the Marquee or Game name. Perhaps it can solve it somehow.
-
The following code will write the current game name to "/.attract/current_name.txt", the current game title to "/.attract/current_title.txt", and the current system to "/.attract/current_system.txt". Hopefully this will get you started, you can paste this into a new plugin or just as part of your layout script....
fe.add_transition_callback( "gamename_transition" );
function gamename_transition( ttype, var, ttime )
{
if (( ttype == Transition.EndNavigation )
|| ( ttype == Transition.StartLayout ))
{
system( "echo '" + fe.game_info( Info.Name ) + "' > ~/.attract/current_name.txt" );
system( "echo '" + fe.game_info( Info.Title ) + "' > ~/.attract/current_title.txt" );
system( "echo '" + fe.game_info( Info.System ) + "' > ~/.attract/current_system.txt" );
}
return false;
}
cheers
-
Thank you very much, it works perfectly... ;D ;D ;D
-
A final thought: You may want to write the file to the ram disk /dev/shm to avoid constant disk writes while browsing the games list.
-
Can you specify this? I'm not avoiding new ideas.
-
The simplest way would be to change the path in raygun's code from "~/.attract/current_name.txt" to "/dev/shm/current_name.txt". The rest depends on how you process the file further for your LED panel. In a nutshell, you would only have to change the path wherever it is used or create a soft link to the file from its former location. (I can tell you how if you need it.)
Remember though that the contents of a ramdisk won't survive a reboot, so there wouldn't be an initial file before AM writes it again. That may cause problems if the LED code isn't prepared for a missing file. You could create one at boot time with this command:
echo "Retropie" > /dev/shm/current_name.txt
(Change "Retropie" to whatever you want to be in the initial current_name.txt.)
In Retropie, you can put this line at the start of the file /opt/retropie/configs/all/autostart.sh ahead of any other commands there to execute it at boot time.
-
Thank you for the explanation.
How to make a soft link to the file from its former location?
-
ln -s /dev/shm/current_name.txt ~/.attract/current_name.txt
Whereby /dev/shm/current_name.txt is the actual file and ~/.attract/current_name.txt is the symbolic link (symlink, soft link).
All writing directed to the link will actually be done to the file.
-
Remember though that the contents of a ramdisk won't survive a reboot, so there wouldn't be an initial file before AM writes it again. That may cause problems if the LED code isn't prepared for a missing file.
That still applies to the symlink method. If the link points to a non-existing file, reading the link will still produce the error "no such file or directory" like reading from the missing file directly. Writing will work normally, though. If something writes to the link, a missing target file will be created automatically.
So, you will still need to create the file at boot time if its absence causes problems. (But only then.)
-
Thanks for your help, let me know how it works. ;)
-
The following code will write the current game name to "/.attract/current_name.txt", the current game title to "/.attract/current_title.txt", and the current system to "/.attract/current_system.txt". Hopefully this will get you started, you can paste this into a new plugin or just as part of your layout script....
fe.add_transition_callback( "gamename_transition" );
function gamename_transition( ttype, var, ttime )
{
if (( ttype == Transition.EndNavigation )
|| ( ttype == Transition.StartLayout ))
{
system( "echo '" + fe.game_info( Info.Name ) + "' > ~/.attract/current_name.txt" );
system( "echo '" + fe.game_info( Info.Title ) + "' > ~/.attract/current_title.txt" );
system( "echo '" + fe.game_info( Info.System ) + "' > ~/.attract/current_system.txt" );
}
return false;
}
cheers
Is there a command that would run a bash script when choosing a system or game?
Thank you for your help.