Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: bjose2345 on August 11, 2017, 12:19:07 AM
-
Hi good fellas, i have the next question and I hope someone could help me on this
I'm looking to keep a list of the last 10 games played, there's a way to do that? I know that there is a functionality but I have not seen anything in the official documentation or forums.
Thanks and kind regards.
-
I sorted this through a shell script, if some one want it I can post it, but still I'm perfecting it.
-
would not mind peeking at it...i think its a good idea.
-
Yes, please share :)
-
Does attract mode load the romlist after return from game? If so, you could use a plugin that will modify the romlist during to game transition, all in squirrel.
-
Add in Favorite filter
-
Add in Favorite filter
There already is favorites filter built into attractmode.
-
Does attract mode load the romlist after return from game? If so, you could use a plugin that will modify the romlist during to game transition, all in squirrel.
yeah i do that but with a shell script, here is the script
first you need to add this code in your theme, remember to register it like a callback function
function on_transition( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.ToGame:
fe.plugin_command_bg( "/home/pi/.attract/runcommand-lastplayed.sh", "\"" + fe.game_info(Info.Name) + ";" + fe.game_info(Info.Title) + ";" + fe.game_info(Info.Emulator) + "\"" );
break;
}
and here the shell script
#!/usr/bin/env bash
# get the args
args="$1"
IFS=';' read -r -a array <<< "$args"
filename="/home/pi/.attract/romlists/Last Played Games.txt"
NUMOFLINES=$(wc -l < "$filename")
$(grep -q "${array[0]};${array[1]};${array[2]};;;;;;;;;;;;;;" "$filename")
if [ $? -eq 1 ]; then
if [ $NUMOFLINES -lt 11 ]; then
sed -i -e '$a\'"${array[0]};${array[1]};${array[2]};;;;;;;;;;;;;;" "$filename"
else
sed -i '2d' "$filename"
sed -i -e '$a\'"${array[0]};${array[1]};${array[2]};;;;;;;;;;;;;;" "$filename"
fi
fi
you can modify this line
if [ $NUMOFLINES -lt 11 ]; then
with any number you want if you want the last 20, put 21, because you need always 1 line in your romlist, the sed command doesnt work in empty files.