@mitu @BuZz @Efriim I finally got it working! :D
local bin_file
local bin_files
local default
local id
local index
local version
... some other code ...
for index in "${!bin_files[@]}"; do
default=0
[[ "$index" -eq "${#bin_files[@]}-1" ]] && default=1 # Default to the last item in 'bin_files'.
version="${bin_files[$index]}"
version="$(echo $version | cut -d'_' -f 2)"
addEmulator "$default" "$md_id-$version-$id" "godot-engine" "$md_inst/${bin_files[$index]} --main-pack %ROM%"
done
So it seems like the error had something to do with the index variable (previously it was named i). Either it needed to be initialized as a local variable or the script didn't like that it was called i... I really don't know. But I got it working :)
Another thing that I found and maybe it's worth mentioning (and correct me if I'm wrong) is that when I run:
sudo ./retropie_packages.sh godot-engine configure
the config file:
/opt/retropie/configs/godot-engine/emulators.cfg
seems to just add the new stuff on top of the previous configs that were already there. I mean, it doesn't delete the file and creates it again with the new configs.
Shouldn't "deleting the old file and creating a new one" be the "correct" thing to do?
Thanks! :)