Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - spud1

Pages: 1 2 [3]
31
General / Re: Opening Display to first game in a romlist
« on: October 21, 2018, 03:42:58 PM »
Thanks keilmillerjr.  Works perfectly:

Code: [Select]
// This plugin ensures that when a Display is opened, the first game in the romlist is in focus
fe.add_transition_callback( "first_game" );
function first_game( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ToNewList:
          fe.list.index = 0     
        return false;
}}

I've added it to the bottom of my layout in layout.nut and it does what I want it to do.



32
General / Re: Opening Display to first game in a romlist
« on: October 20, 2018, 03:48:09 PM »
Thanks, guys. 

I haven't got very far on this, as I'm not certain how to show "index = 0".

Code: [Select]
// This plugin ensures that when a Display is opened, the first game in the romlist is in focus
fe.add_transition_callback( "first_game" );
function first_game( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ToNewList:
          index = 0     
        return false;
}}

I only really want to do this with one layout.  Once I've got the plugin sorted, can I add the same code just to one layout.nut and it should work?

33
General / Re: Attract Mode and stats folder
« on: October 18, 2018, 02:49:50 PM »
Thank you so much for that explanation.

34
General / Opening Display to first game in a romlist
« on: October 17, 2018, 11:33:54 PM »
Hi.  Is there a way of making sure every time a Display opens, it opens to the first game listed at the top of a Romlist?

35
General / Attract Mode and stats folder
« on: October 16, 2018, 04:09:39 PM »
I know that Attract Mode can record both the Play Count and the Time Played in the stats folder.

For example, in my /home/pi/.attract/stats/FBA folder, I've got a 1941.stat with the following lines:
1
7

I know that the "1" represents the play count.  Does the "7" represent the amount of time?  Is this in seconds?

Has anyone found a way of using this information in Attract Mode?

36
Hi wrybread. I would be very interested in your code if you are willing to publish it please. I'm using linux/ raspberry pi. Thanks.

37
Scripting / Re: Last Played Games - Most recent Games list
« on: October 12, 2018, 03:13:48 PM »
Updated script:

Code: [Select]
// This plugin saves the most recently played game to the "Last_Played_Games.txt" romlist
fe.add_transition_callback( "most_recent_game" );
function most_recent_game( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ToGame:
                system( "echo '" + fe.game_info( Info.Name ) + ";" + fe.game_info( Info.Title ) + ";" + fe.game_info( Info.Emulator ) + ";" + fe.game_info( Info.CloneOf ) + ";" + fe.game_info( Info.Year ) + ";" + fe.game_info( Info.Manufacturer ) + ";" + fe.game_info( Info.Category ) + ";" + fe.game_info( Info.Players ) + ";" + fe.game_info( Info.Rotation ) + ";" + fe.game_info( Info.Control ) + ";" + fe.game_info( Info.Status ) + ";" + fe.game_info( Info.DisplayCount ) + ";" + fe.game_info( Info.DisplayType ) + ";" + fe.game_info( Info.AltRomname ) + ";" + fe.game_info( Info.AltTitle ) + ";" + fe.game_info( Info.Extra ) + ";" + fe.game_info( Info.Buttons ) + "' >> ~/.attract/romlists/Last_Played_Games.txt" ); // Takes the details of the game most recently played and inserts them at the end of the Last_Played_Games.txt romlist
                system( "tac ~/.attract/romlists/Last_Played_Games.txt | awk 'NR==1 {a=$0; next} 1; END{print a}' | tac > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Takes the most recently played game and moves it to the start of the romlist
                system( "awk '!/Mode/' ~/.attract/romlists/Last_Played_Games.txt > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Removes any reference in the romlist to a restart of Attract Mode
                system( "awk '!x[$0]++' ~/.attract/romlists/Last_Played_Games.txt > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Removes duplicate entries in the romlist, leaving only the first (and most recent) entry for a particular game
                system( "printf '%s\n' 1m3 3-m1- w q | ed -s ~/.attract/romlists/Last_Played_Games.txt" ); // Swaps the most recently played game at line 1 to line 3 so that the game is shown first (gives it focus) on opening the Most Recently Played Games theme
        return false;
}}

38
Scripting / Re: Last Played Games - Most recent Games list
« on: October 09, 2018, 02:43:03 AM »
I wound up solving the problem I had by creating a separate plugin rather than including the code in the layout.nut.

The LastPlayedGame.nut plugin looks like this:

Code: [Select]
// This plugin saves the most recently played game to the "Last_Played_Games.txt" romlist
fe.add_transition_callback( "most_recent_game" );
function most_recent_game( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ToGame:
                system( "echo '" + fe.game_info( Info.Name ) + ";" + fe.game_info( Info.Title ) + ";" + fe.game_info( Info.Emulator ) + ";" + fe.game_info( Info.CloneOf ) + ";" + fe.game_info( Info.Year ) + ";" + fe.game_info( Info.Manufacturer ) + ";" + fe.game_info( Info.Category ) + ";" + fe.game_info( Info.Players ) + ";" + fe.game_info( Info.Rotation ) + ";" + fe.game_info( Info.Control ) + ";" + fe.game_info( Info.Status ) + ";" + fe.game_info( Info.DisplayCount ) + ";" + fe.game_info( Info.DisplayType ) + ";" + fe.game_info( Info.AltRomname ) + ";" + fe.game_info( Info.AltTitle ) + ";" + fe.game_info( Info.Extra ) + ";" + fe.game_info( Info.Buttons ) + "' >> ~/.attract/romlists/Last_Played_Games.txt" ); // Takes the details of the game most recently played and inserts them at the end of the Last_Played_Games.txt romlist
                system( "tac ~/.attract/romlists/Last_Played_Games.txt | awk 'NR==1 {a=$0; next} 1; END{print a}' | tac > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Takes the Game's details and moves them to the start of the romlist
                system( "awk '!/Mode/' ~/.attract/romlists/Last_Played_Games.txt > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Removes any reference in the romlist to a restart of Attract Mode
                system( "awk '!x[$0]++' ~/.attract/romlists/Last_Played_Games.txt > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Removes duplicate entries in the romlist, leaving only the first (and most recent) entry for a particular game
                system( "head -51 ~/.attract/romlists/Last_Played_Games.txt > ~/.attract/romlists/Last_Played_Games1.txt && rm ~/.attract/romlists/Last_Played_Games.txt && mv ~/.attract/romlists/Last_Played_Games1.txt ~/.attract/romlists/Last_Played_Games.txt" ); // Limits the number of entries in the romlist to 51
        return false;
}}

You could safely remove the third "system" line - that is unique to my system.

Don't forget to enable the plugin.  I have set up a "Most Recent Games" display for the "Last_Played_Games.txt" romlist and it is working perfectly for me.

39
Scripting / Re: Last Played Games - Most recent Games list
« on: October 07, 2018, 01:53:40 AM »
I've tried all sorts to get this working.  I've updated my Attract Mode to the latest version from 2.3.0.   I've checked that the bash script itself works from the command line, which it does.  The problem seems to be with the layout.nut.    It doesn't seem to pass the arguments to the bash script and fails to invoke it.

I've also tried another script (below) found in the forum (http://forum.attractmode.org/index.php?topic=2420.0) as well to see whether this other script writes to a file as it is intended to do.  It doesn't work for me either.  Could anyone who is using a Raspberry Pi and Retropie make any suggestions please?  It looks to me as though the layout.nut isn't invoking the bash scripts for some reason.  Thanks for any suggestions.

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

40
Scripting / Last Played Games - Most recent Games list
« on: October 03, 2018, 04:06:13 PM »
Hi.  I'm trying to produce a "last played games" romlist for Attract Mode.

I've tried to get this script to work but unsuccessfully: http://forum.attractmode.org/index.php?topic=1843.0

What I have so far in the layout.nut is:

Code: [Select]
// Most recently played games will be listed in the "Last Played Games.txt" romlist
fe.add_transition_callback( "on_transition" );
function on_transition( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ToGame:
  fe.plugin_command_bg( fe.script_dir + "runcommand-lastplayed.sh", "\"" + fe.game_info( Info.Name ) + ";" + fe.game_info( Info.Title ) + ";" + fe.game_info( Info.Emulator ) + "\"" );
  break;
 }
 return false;
 }
}}

And the executable bash script runcommand-lastplayed.sh (which is in the same folder as layout.nut) is as follows:
Code: [Select]
#!/bin/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 51 ]; 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
I've also added a "Last Played Games.txt" romlist  in the right location with an initial line at the top so the file is not empty.

However, I can't get this to work.  It adds nothing to the "Last Played Games.txt".  Could anyone help please?  Thanks.

Pages: 1 2 [3]