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.


Topics - spud1

Pages: [1]
1
General / Echo or print name of romlist
« on: April 25, 2019, 06:01:29 AM »
In a Plugin I've created, I'm able to send the name of the Display to a file by using the command:

fe.plugin_command( "/usr/bin/printf9.sh", "\"" + fe.list.name + "\"" );

The above plugin command then invokes the printf9.sh bash script as follows;

#!/bin/bash
sudo /usr/bin/printf "$1" > "/home/pi/.attract/romlists/FAVOURITES/$1.temp"


However, instead of the name of the Display (ie fe.list.name), is there a way of sending the name of the Romlist to a file please?

2
I've got a Plugin that works for every Layout/Display.  However, I'd like it to work with every Layout/Display EXCEPT one.  Is it possible to do this with an if/else statement or some other way please?

Code: [Select]
// This plugin adds a newly "favourited" game to the "Favourites.txt" romlist
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.ChangedTag:
fe.plugin_command( "/usr/bin/printf5.sh", "\"" + fe.game_info(Info.Name) + "\"" );
fe.plugin_command( "/usr/bin/printf6.sh", "\"" + 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) + "\"" );
system( "sudo /bin/bash /bin/addfavourite.sh" );
}
return false;
}
fe.add_transition_callback( "favourites" )

Thanks.

3
I have a module/plugin which generally works.  It's designed to take the name of the rom and dump it into a text file for further processing.  It works with most games but I can't get it to work with rom names that include a single apostrophe (eg Sam's Journey) or games with any kind of brackets (eg Sam's Journey (Easyflash) or Sam's Journey [Easyflash]).  I was hoping someone might be able to help please.

The module is as follows:

Code: [Select]
fe.add_transition_callback( "removefavourite" );
function removefavourite( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "echo '" + fe.game_info( Info.Name ) + "' > /home/pi/.attract/romlists/REMOVEFAVOURITE.temp" ); // Takes the romname "unfavourited" by me in Favourites.txt and inserts it into REMOVEFAVOURITE.temp for further processing
        return false;

Interestingly, I can get the code to work from the terminal eg
Code: [Select]
echo "Sam's Journey (Easyflash)" > /home/pi/.attract/romlists/REMOVEFAVOURITE.temp and
Code: [Select]
echo "Sam's Journey [Easyflash]" > /home/pi/.attract/romlists/REMOVEFAVOURITE.temp, but not if single quotations are used eg
Code: [Select]
echo '"Sam's Journey (Easyflash)"' > /home/pi/.attract/romlists/REMOVEFAVOURITE.temp
I don't think it's a problem with the fe.game-info part of the code.  It probably has something to do with the multiplicity of single and double quotations.  The use of the single quotations eg
Code: [Select]
echo '" + fe.game_info( Info.Name ) + "' in this code seems to mean it won't recognise the brackets, but it appears to need the single quotations in the module/plugin for it to work at all with other games that don't have brackets or apostrophes in their names. 

I've also tried printf instead of echo with the same result.

If anyone can help please, I would be grateful.  Thanks.


4
Scripting / Creating a Delay before initiating another plugin script
« on: December 22, 2018, 02:09:47 PM »
I would be very grateful for some help please.  I'm trying to create a delay before initiating a plugin, but am struggling to get the syntax right.  I've looked at various scripts on the forum, including timer.nut, but have been unsuccessful in adapting any of them.

I have 3 plugins as follows.  The first plugin called "Favourites.nut" initiates a series of bash scripts in the background.  This plugin also initiates the second plugin called "Delay.nut".  I'd like "Delay.nut" to wait 10 seconds, then call upon the third plugin.  The third plugin is called "RestartFavourites.nut" which switches to my Favourites layout.

The code I have so far is as follows.  First plugin - Favourites.nut:

Code: [Select]
// This plugin regenerates the "Favourites.txt" romlist when a game is selected as a favourite or deselected as a favourite
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "sudo /bin/bash /opt/retropie/configs/all/favourites.sh" ); // Starts the Favourites bash script to update the Favourites romlist whenever a game is tagged or untagged
fe.do_nut("Delay.nut");
        return false;
}}

Second plugin - Delay.nut:

Code: [Select]
// This plugin delays switching back to the Favourites layout
fe.add_ticks_callback( "delay" );
function delay( ttime )
{
fe.do_nut("RestartFavourites.nut");
        return false;
}}

Third plugin - RestartFavourites.nut:

Code: [Select]
//Restart Favourites layout
function load_display_name(name) {
   foreach( idx, display in fe.displays )
      if ( name == fe.displays[idx].name && name != fe.displays[fe.list.display_index].name ) fe.set_display(idx)
}

load_display_name("Favourites")

Both the first and third plugins work perfectly without Delay.nut, but Delay.nut does not.  Could I please ask for some help to fix Delay.nut so that it waits 10 seconds before triggering RestartFavourites.nut?  Thanks.

I'm familiar with the sleep command for bash scripts and with AutoHotkey scripts for Windows, but I'm using a Raspberry Pi 3B so need to create the delay in Squirrel.

5
I've got a plugin as follows.

Code: [Select]
// This plugin regenerates the "Favourites.txt" romlist when a game is selected as a favourite or deselected as a favourite
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "sudo /bin/bash /opt/retropie/configs/all/favourites.sh" ); // Starts the Favourites bash script to update the Favourites romlist whenever a game is tagged or untagged
        return false;
}} 

The above code works well for every layout/display by invoking the favourites.sh bash script.

However, I'd also like to include some "Transition.ChangedTag" code in one layout only. 

I've got the following code in one of my layouts/displays, but it does not work.  I'm not sure why:

Code: [Select]
fe.add_transition_callback( "remove_favourite" );
function remove_favourite( ttype, var, ttime )
{ if ( ttype == Transition.EndNavigation || ttype == Transition.ChangedTag )
        {
                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;
}

Basically, on removing a game as a favourite from a particular romlist, I'd like to record some information about the game that has been removed.  However, the above code doesn't produce the current_name.txt file or the other files. 

Could I please ask for some help?  Thanks.

6
Scripting / Getting fe.plugin_command_bg to work
« on: October 25, 2018, 01:39:39 AM »
When exiting a game on my Raspberry Pi3B and going back to Attract Mode, I'd like to execute a bash script.  I can get the script to work using the `system` command in the plugin.  However, I'd like the bash script to operate in the background because it causes a 5 to 10 second delay to returning to Attract Mode.

For the life of me, though, I can't get fe.plugin_command_bg to work with any executable file.  I'm on the latest 4.2.1 version of Attract Mode.  I'd be grateful for any help please.  Thanks.  The plugin is below:

Code: [Select]
// This plugin regenerates the "Most_Played_Games" romlists when a game is played
fe.add_transition_callback( "most_played_game" );
function most_played_game( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.FromGame:
                fe.plugin_command_bg( "sudo /home/pi/.attract/MPG.sh", "" ); // Starts the Most Played Games bash script to update the Most_Played_Games_By_Play_Count and Most_Played_Games_By_Play_Time romlists whenever a game is played
                break;
                }
                return false;
}

7
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?

8
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?

9
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]