Automated Switchable RetroAchievements [cheevos]
-
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, thencheevos_enabled
will be set to false and there will be no connection to the RetroAchievements server.We need to edit
runcommand-onstart.sh
withnano /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 ;) -
@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.
-
@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...
- for the paranoid people out here
- to push the RetroAchievements
- to improve my skills
Hope you like it ;)
The >&2 is the
pjft
dedicated log event to runcommand.log ... -
Could someone do an ELI5* on this?
*Explain like I'm five
-
@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-collection
like RetroAchievments-collection or RA - Battle Bugs-collectionGot it?
-
@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.
-
@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.
-
@cyperghost now you can play Bubble Bath Babes (NES) with more privacy! :D
Credit: Thanks @cabrunco for the joke.
-
@meleu Only for that ...
"Scotty doesn't know" ;)
-
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 ;)
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.