RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Using custom script that is not runcommand.sh does not work

    Scheduled Pinned Locked Moved Help and Support
    scripting
    36 Posts 3 Posters 4.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RetroFloppy08 @Folly
      last edited by

      @Folly Looking at the link, it's not exactly what i'm looking for. I shouldn't need too much code, just some if else statements.

      F R 2 Replies Last reply Reply Quote 0
      • F
        Folly @RetroFloppy08
        last edited by

        @RetroFloppy08

        And did you try the suggestions earlier in the thread ?

        1 Reply Last reply Reply Quote 0
        • R
          RetroFloppy08 @RetroFloppy08
          last edited by

          @RetroFloppy08 Of course, I would need some kind of way to load the ROM's filename in question. That's the problem i'm facing currently.

          F 1 Reply Last reply Reply Quote 0
          • F
            Folly @RetroFloppy08
            last edited by

            @RetroFloppy08

            From the CLI or from emulationstation ?

            R 1 Reply Last reply Reply Quote 0
            • R
              RetroFloppy08 @Folly
              last edited by

              @Folly EmulationStation.

              F 1 Reply Last reply Reply Quote 0
              • F
                Folly @RetroFloppy08
                last edited by

                @RetroFloppy08

                You need somehow to add an other system that will load the .chd file and redirects it to your bash script which will detect the extension and then uses the correct runcommand.

                R 1 Reply Last reply Reply Quote 0
                • R
                  RetroFloppy08 @Folly
                  last edited by

                  @Folly That's what I've done. I made a seperate system reserved for loading games from the disc. It also uses the custom script.

                  F 1 Reply Last reply Reply Quote 0
                  • F
                    Folly @RetroFloppy08
                    last edited by

                    @RetroFloppy08

                    So what is your custom system name then ?
                    And how did you configure it ?

                    R 1 Reply Last reply Reply Quote 0
                    • R
                      RetroFloppy08 @Folly
                      last edited by

                      @Folly If you look at the initial post, you can see the system entry.

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        Folly @RetroFloppy08
                        last edited by Folly

                        @RetroFloppy08

                        Is that all you added ?
                        You will need to add much more to get it working.

                        So you have 2 choices.
                        Make a module-script like the example I gave you earlier , or do all the setting manually.
                        You can have a look here on how to do it manually :
                        https://retropie.org.uk/forum/topic/28462/tutorial-handheld-and-plug-play-systems-with-mame

                        And replace mame or emulator with your script and no need to use some retroarch.cfg.

                        R 1 Reply Last reply Reply Quote 0
                        • R
                          RetroFloppy08 @Folly
                          last edited by

                          @Folly Hmm. Seems like I've got a lot of work to do. I'll let you know how it goes.

                          F 1 Reply Last reply Reply Quote 0
                          • F
                            Folly @RetroFloppy08
                            last edited by

                            @RetroFloppy08

                            Can you filter all the nonsense and pick the correct things for yourself ?

                            R 1 Reply Last reply Reply Quote 0
                            • R
                              RetroFloppy08 @Folly
                              last edited by

                              @Folly I can certainly try. I'm seeing some key things already, for example lines at the end that use the %ROM% argument to load a file from EmulationStation.

                              F 1 Reply Last reply Reply Quote 0
                              • F
                                Folly @RetroFloppy08
                                last edited by

                                @RetroFloppy08

                                Ok, good luck.

                                Try this first, otherwise I recommend you to make a module-script.
                                Once you know how, then it's the easiest way.

                                R 1 Reply Last reply Reply Quote 0
                                • R
                                  RetroFloppy08 @Folly
                                  last edited by

                                  @Folly 03194593-0046-4323-8de9-8c6338d71ef9-image.png These are the lines I have narrowed down. I have a feeling they're wrong, so if they are, please tell me.

                                  F 1 Reply Last reply Reply Quote 0
                                  • S
                                    sleve_mcdichael @RetroFloppy08
                                    last edited by

                                    @RetroFloppy08 said in Using custom script that is not runcommand.sh does not work:

                                    @sleve_mcdichael What argument am I supposed to attach to the command to load the filename?

                                    %ROM% in the <command> string is used by EmulationStation and is replaced by the actual rom file you've selected. So for example if your <commamd> is bash /test/script.sh %ROM% and you select the game "Foorio in Foo Land" for the "Foo Bar Entertainment System" then ES is going to run:

                                    bash /test/script.sh "/home/pi/RetroPie/roms/fbes/Foorio in Foo Land (USA, Zanzibar) (Rev B).foo"
                                    

                                    Your script will then need to parse this as $1 or, "first argument."

                                    I wonder if the spaces are maybe tripping it up. Try wrapping $1 in quotes, like "$1":

                                    [[ "$1" == *.chd ]] && /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ psx "$1"
                                    

                                    ...or try "$*" ("all arguments") instead of "$1" (first argument) (still in quotes).

                                    1 Reply Last reply Reply Quote 0
                                    • F
                                      Folly @RetroFloppy08
                                      last edited by Folly

                                      @RetroFloppy08 said in Using custom script that is not runcommand.sh does not work:

                                      @Folly 03194593-0046-4323-8de9-8c6338d71ef9-image.png These are the lines I have narrowed down. I have a feeling they're wrong, so if they are, please tell me.

                                      Not sure what you are doing with this.
                                      My script works, but not for your purpose.
                                      The module-script is just an example, if you want to use it you to completely rewrite it for your needs.

                                      My advise was to make a custom system manually first.
                                      If that doesn't work we can talk about making a module-script.

                                      R 1 Reply Last reply Reply Quote 0
                                      • R
                                        RetroFloppy08 @Folly
                                        last edited by

                                        @Folly I've actually gotten the script to work. I reworked how the if statement is processed, and it works like a charm. Instead of isolating the extension (as initially suggested by @sleve_mcdichael) I instead told the program to read the last 4 characters of the filename. It works now, all I need to do is make more discs with different files, and add some else if statements. I'll post the script once it's finished.

                                        F 1 Reply Last reply Reply Quote 0
                                        • F
                                          Folly @RetroFloppy08
                                          last edited by

                                          @RetroFloppy08

                                          Good work !
                                          Curious what you made ;-)

                                          R 1 Reply Last reply Reply Quote 0
                                          • R
                                            RetroFloppy08 @Folly
                                            last edited by

                                            @Folly @sleve_mcdichael Alright, it's done. I present to you the script to load games based off of their filenames. This is the version I have, and it works very well. The selection is limited, but the good news is you can select for yourself what file types are supported. Have fun!

                                            #!/bin/bash
                                            
                                            rom="$1"
                                            
                                            if [ "${1: -4}" == ".chd" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ psx "$1"
                                            elif [ "${1: -4}" == ".bin" ] || [ "${1: -3}" == ".md" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ megadrive "$1"
                                            elif [ "${1: -4}" == ".nes" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nes "$1"
                                            elif [ "${1: -4}" == ".smc" ] || [ "${1: -4}" == ".sfc" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ snes "$1"
                                            elif [ "${1: -4}" == ".z64" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ n64 "$1"
                                            elif [ "${1: -4}" == ".gba" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ gba "$1"
                                            elif [ "${1: -4}" == ".zip" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ mame-libretro "$1"
                                            elif [ "${1: -3}" == ".gb" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ gb "$1"
                                            elif [ "${1: -4}" == ".gbc" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ gbc "$1"
                                            elif [ "${1: -4}" == ".fds" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ fds "$1"
                                            elif [ "${1: -4}" == ".nds" ]
                                            then
                                            /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nds "$1"
                                            fi
                                            
                                            1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.