• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login

Automated Switchable RetroAchievements [cheevos]

Scheduled Pinned Locked Moved Ideas and Development
cheevosautomatedcyperghost
10 Posts 4 Posters 3.1k 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.
  • C
    cyperghost
    last edited by cyperghost 9 Nov 2017, 20:24 11 Sept 2017, 18:19

    As @meleu opened the thread RetroAchievements in a Nutshell I entered the RA experience. It's really nice what in RA can be done and achieved and with much love and true dedidaction the members there made some interest games much more interesting and adoreable.

    As there is no easy on/off switch for the RetroAchievement integration in Retroarch and I do not want that every game is listed into the RetroAchievements games ladder list - I just wrote a quick script that automates the process.

    As key event custom-collections are used. The script compares entries of one or more dedicated cutom-collections and if there is a hit then the RA-flag (cheevos_enabled) will be set to true. If the currently loaded ROM is not in the RA-custom-collection, then cheevos_enabled will be set to false and there will be no connection to the RetroAchievements server.

    We need to edit runcommand-onstart.sh with nano /opt/retropie/configs/all/runcommand-onstart.sh

    We add line

    # optional RetroAchivements.sh "$3" "$1" if there are different settings for emulators
    /path/RetroAchievements.sh "$3"

    The parameter $3 pathes full ROM-filename to the script.
    The $1 is optional, if it isn't used then the "/opt/retropie/configs/all/retroarch.cfg" will be used otherwise a system separated setting is possible.

    Please setup "array_cheevos" first. I use "RetroAchievements" and "RA - Battle Bugs" as my two dedicated custom-collections for RA

    Ghostbin: https://ghostbin.com/paste/ec89e

    @pjft This is not a hack now!
    @meleu Just want to say thank you ;)

    #!/bin/bash
    # RetroAchievements - automatic v1.0 by cyperghost aka crcerror
    # Synopsis!
    # This script enables the RetroAchievement flag from games that are stored in
    # a dedicated custom-collection. This custom collection must be added to the
    # array_cheevos variable. So this script enables in default mode the connection
    # to the RA server and closes it if the game is not "marked" as Achievement.
    # Settings mode
    # 0 = disable this script
    # 1 = set cheevos_enable flag true if game is in Achievements-Collection
    # and sets chevos_enalbe flag to false if it is not! (DEFAULT!)
    # 2 = set cheevos_enable flag true if game is in Achievements-Collection
    # but does nothing if annother game is not in Achievements-Collection
    # 3 = enable achivments at every run, there is no disabeling!
    # 4 = disable achivments at every run, there is no enabling!
    script_mode=1
    # Array of location to Achievements-Collection
    # As the collection files are usual text files we can just cross check
    # existane of ROM files in collection
    # Please enter full path and filename to collection - they are case sensitive!
    array_cheevos=("/opt/retropie/configs/all/emulationstation/collections/custom-RA - Battle Bugs.cfg" \
    "/opt/retropie/configs/all/emulationstation/collections/custom-RetroAchievements.cfg")
    ### DEBUG (this is runcommand $3 in callingscript)
    es_rom="$1"
    ### DEBUG (this is runcommand $1 in callingscript)
    # --> build path /opt/retropie/configs/$1/retroarch.cfg
    # If no parameter pathed use /opt/retropie/configs/all/retroarch.cfg
    es_sys="/opt/retropie/configs/$2/retroarch.cfg"
    [[ -z "$2" ]] && es_sys="/opt/retropie/configs/all/retroarch.cfg"
    # -- F U N C T I O N S --
    # function determinating the cheevos-flag from retroarch.cfg for called sys
    # function calls are on/off for enabling/disableling cheevos function
    # status for checking if cheevos are enabled/disabled out of $/$sys/retroarch.cfg
    # personally that's my first RegEx lesson
    func_cheevos()
    {
    case "${1^^}" in
    "OFF")
    sed -i -e "s|^cheevos_enable\ *=\ *\"*true\"*|cheevos_enable = \"false\"|" \
    "$es_sys" &> /dev/null
    ;;
    "ON")
    sed -i -e "s|^cheevos_enable\ *=\ *\"*false\"*|cheevos_enable = \"true\"|" \
    "$es_sys" &> /dev/null
    ;;
    "STATUS")
    grep "cheevos_enable\ *=\ *\"*true\"*" &> /dev/null \
    "$es_sys" && ra_cheevos=1
    ;;
    esac
    }
    # -- M A I N --
    # Ask for status of cheevos of current system (/opt/retropie/config/$sys/retroarch.cfg)
    func_cheevos status
    # Open array and search collections entries for started ROM
    # While loop reads entries line by line
    # There is a check performed that checks collection-file existance!
    # Annother approch could be \for a in ${array_cheevos[@]}\ but like idx's
    while [[ "$idx" -lt "${#array_cheevos[@]}" ]]
    do
    ! [[ -f "${array_cheevos[$idx]}" ]] \
    && echo "RetroAchievements.sh: Collection file ${array_cheevos[$idx]} not found" >&2 \
    && exit 1
    while read line
    do
    [[ "$line" == "$es_rom" ]] && col_cheevos=1 #<-- Found ROM in Collection
    done < "${array_cheevos[$idx]}"
    idx=$(( $idx + 1 ))
    done
    # Use Cases
    case "$script_mode" in
    0)
    echo "0:RetroAchievements.sh: script_mode is setted to 0 - Exit" >&2
    ;;
    1)
    echo "1:RetroAchievements.sh: (0$ra_cheevos): retroarch.cfg - (0$col_cheevos):" \
    "cheevo found for $es_rom" >&2
    [[ "$col_cheevos" ]] && [[ -z "$ra_cheevos" ]] && func_cheevos on
    [[ -z "$col_cheevos" ]] && [[ "$ra_cheevos" ]] && func_cheevos off
    ;;
    2)
    echo "2:RetroAchievements.sh: (0$ra_cheevos): retroarch.cfg - (0$col_cheevos):" \
    "cheevo found for $es_rom" >&2
    [[ "$col_cheevos" ]] && [[ -z "$ra_cheevos" ]] && func_cheevos on
    ;;
    3) echo "3:RetroAchievements.sh: Enable RetroAchievments for system: $es_sys" >&2
    [[ -z "$ra_cheevos" ]] && func_cheevos on
    ;;
    4) echo "4:RetroAchievements.sh: Disable RetroAchievments for system: $es_sys" >&2
    [[ "$ra_cheevos" ]] && func_cheevos off
    ;;
    esac

    PS: All messages are logged to /dev/shm/runcommand.log
    Knowledge is surly power ;)

    P M 2 Replies Last reply 11 Sept 2017, 18:35 Reply Quote 3
    • P
      pjft @cyperghost
      last edited by 11 Sept 2017, 18:35

      @cyperghost I don't have any particular issue with hacks:) it's just when they get out of control that I start to worry.

      Thanks for putting this together. I still owe @meleu an achievements metadata field in ES. Hopefully I'll get a new development environment - and free time - sorted before end of month.

      1 Reply Last reply Reply Quote 2
      • C
        cyperghost
        last edited by cyperghost 9 Nov 2017, 19:42 11 Sept 2017, 18:40

        @pjft I know you are working on a cheevos-flag ;) But then this script can be modified as the function calls can be still used. I just made a quick coding...

        1. for the paranoid people out here
        2. to push the RetroAchievements
        3. to improve my skills

        Hope you like it ;)

        The >&2 is the pjftdedicated log event to runcommand.log ...

        1 Reply Last reply Reply Quote 0
        • L
          lilbud
          last edited by 11 Sept 2017, 18:42

          Could someone do an ELI5* on this?

          *Explain like I'm five

          Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

          Backlog: http://backloggery.com/lilbud

          C 1 Reply Last reply 11 Sept 2017, 18:44 Reply Quote 0
          • C
            cyperghost @lilbud
            last edited by 11 Sept 2017, 18:44

            @lilbud Uff....
            If you activate RetroAchievements then every game access will be logged to their servers and your playlist will grow and grow.

            So I decided to activate RetroAchievements only for games that are stored in a custom-collectionlike RetroAchievments-collection or RA - Battle Bugs-collection

            Got it?

            L 1 Reply Last reply 11 Sept 2017, 18:47 Reply Quote 0
            • L
              lilbud @cyperghost
              last edited by 11 Sept 2017, 18:47

              @cyperghost Ah, got it.

              So when you have achievements enabled, a custom system will be created in ES that lists the games that have cheats enabled.

              Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

              Backlog: http://backloggery.com/lilbud

              C 1 Reply Last reply 11 Sept 2017, 18:58 Reply Quote 0
              • C
                cyperghost @lilbud
                last edited by cyperghost 9 Nov 2017, 20:00 11 Sept 2017, 18:58

                @lilbud No...
                You have to create a custom-collection and set it to this script. Then RA will be enabeld or disabeld. RetroAchievements are not CHEATS... it's an achievement and ladder system for retrogames like for Playstation or XBOX networks ;)

                Every login and played game will be registered to their system so it's a good approach to activate the system just for games you want to get Achievements. You can click @meleu 's link in the first posting to step in.

                1 Reply Last reply Reply Quote 0
                • M
                  meleu @cyperghost
                  last edited by 11 Sept 2017, 19:53

                  @cyperghost now you can play Bubble Bath Babes (NES) with more privacy! :D

                  Credit: Thanks @cabrunco for the joke.

                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  C 1 Reply Last reply 11 Sept 2017, 20:06 Reply Quote 1
                  • C
                    cyperghost @meleu
                    last edited by cyperghost 9 Nov 2017, 21:22 11 Sept 2017, 20:06

                    @meleu Only for that ...
                    "Scotty doesn't know" ;)

                    C 1 Reply Last reply 12 Sept 2017, 16:25 Reply Quote 0
                    • C
                      cyperghost @cyperghost
                      last edited by 12 Sept 2017, 16:25

                      This goes hand in hand with @meleu s cheevos scraper!

                      So the possibility to get games marked that have achievements let us easier select them to collections ;)

                      1 Reply Last reply Reply Quote 1
                      10 out of 10
                      • First post
                        10/10
                        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.

                        This community forum collects and processes your personal information.
                        consent.not_received