Author Topic: Last played games  (Read 4993 times)

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Last played games
« 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.
« Last Edit: August 11, 2017, 12:26:42 AM by bjose2345 »

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Last played games
« Reply #1 on: August 14, 2017, 11:52:06 PM »
I sorted this through a shell script, if some one want it I can post it, but still I'm perfecting it.

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Last played games
« Reply #2 on: August 15, 2017, 06:57:38 AM »
would not mind peeking at it...i think its a good idea.
help a friend....

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Last played games
« Reply #3 on: August 15, 2017, 11:43:39 AM »
Yes, please share :)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Last played games
« Reply #4 on: August 15, 2017, 04:17:55 PM »
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.

nevincho

  • Full Member
  • ***
  • Posts: 92
    • View Profile
Re: Last played games
« Reply #5 on: August 15, 2017, 04:21:52 PM »
Add in Favorite filter

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Last played games
« Reply #6 on: August 15, 2017, 07:02:44 PM »
Add in Favorite filter

There already is favorites filter built into attractmode.

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Last played games
« Reply #7 on: August 16, 2017, 12:57:30 AM »
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

Code: [Select]
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

Code: [Select]
#!/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

Code: [Select]
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.
« Last Edit: August 16, 2017, 01:11:26 AM by bjose2345 »