Change DLC_SPACE_AGE to enable specific Space Age mods (#530)

* Change variable DLC_SPACE_AGE to allow listing specific Space Age mods to enable

* Adjust DLC_SPACE_AGE note

Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>

---------

Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
This commit is contained in:
Yannick Beauchamp-H
2024-10-23 17:54:02 -04:00
committed by GitHub
parent 9562212254
commit b20d93e229
2 changed files with 31 additions and 12 deletions

View File

@ -4,6 +4,8 @@ set -eou pipefail
# Path to the mod-list.json file
MOD_LIST_FILE="$MODS/mod-list.json"
ALL_SPACE_AGE_MODS=("elevated-rails" "quality" "space-age")
if [[ ! -f "$MOD_LIST_FILE" ]]; then
# Create the mod-list.json file if it doesn't exist
echo '{"mods":[{"name":"base","enabled":true}]}' > "$MOD_LIST_FILE"
@ -26,18 +28,30 @@ disable_mod()
# Enable or disable DLCs if configured
if [[ ${DLC_SPACE_AGE:-} == "true" ]]; then
# Define the DLC mods
DLC_MODS=("elevated-rails" "quality" "space-age")
# Iterate over each DLC mod
for MOD in "${DLC_MODS[@]}"; do
enable_mod "$MOD"
done
else
ENABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
elif [[ ${DLC_SPACE_AGE:-} == "false" ]]; then
# Define the DLC mods
DLC_MODS=("elevated-rails" "quality" "space-age")
DISABLE_MODS=(${ALL_SPACE_AGE_MODS[@]})
else
ENABLE_MODS=()
DISABLE_MODS=()
# Iterate over each DLC mod
for MOD in "${DLC_MODS[@]}"; do
disable_mod "$MOD"
for SPACE_AGE_MOD in "${ALL_SPACE_AGE_MODS[@]}"; do
REGEX="(^|\s)$SPACE_AGE_MOD($|\s)"
if [[ "$DLC_SPACE_AGE" =~ $REGEX ]]; then
ENABLE_MODS+=($SPACE_AGE_MOD)
else
DISABLE_MODS+=($SPACE_AGE_MOD)
fi
done
fi
# Iterate over each DLC mod to enable
for MOD in "${ENABLE_MODS[@]}"; do
enable_mod "$MOD"
done
# Iterate over each DLC mod to disable
for MOD in "${DISABLE_MODS[@]}"; do
disable_mod "$MOD"
done