factorimods : little cleanup before making public
This commit is contained in:
parent
20f08193d2
commit
ee9cccb2e1
24
factorimods
24
factorimods
@ -1,30 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#Dependencies : you'll need a dmenu-like to run this script.
|
# Dependencies : you'll need a dmenu-like to run this script.
|
||||||
#On debian and debian-like distros (ubuntu, mint...), simply run:
|
# On debian and debian-like distros (ubuntu, mint...), simply run:
|
||||||
# sudo apt install dmenu
|
# sudo apt install dmenu
|
||||||
|
|
||||||
#Edit this line to meet your installation
|
# Edit this line to meet your installation
|
||||||
factorio_dir="/DATA/Games/factorio"
|
factorio_dir="/DATA/Games/factorio"
|
||||||
|
|
||||||
|
# If you have installed new mods, this script will revert to previously saved
|
||||||
|
# mods before launching factorio. To update the modlist for a save, select the
|
||||||
|
# appropriate mods (via the GUI menu in factorio), then exit, call
|
||||||
|
# factorimods -r
|
||||||
|
# and select that save. This will replace the previously saved mods for that
|
||||||
|
# save with the active list from factorio.
|
||||||
cd $factorio_dir/saves
|
cd $factorio_dir/saves
|
||||||
|
|
||||||
#Ask the user to select a save
|
#Ask the user to select a save
|
||||||
save=$(ls -t *.zip | grep -v autosave | rev | cut -d "." -f 2- | rev | dmenu)
|
save=$(ls -t *.zip | grep -v autosave | rev | cut -d "." -f 2- | rev | dmenu -i -l 5 -p "Chose a save file: ")
|
||||||
|
|
||||||
test $? -ne 0 && echo "No save selected" && exit 1
|
test $? -ne 0 && echo "No save selected" && exit 1
|
||||||
|
|
||||||
|
if test $1 = "-r" ; then
|
||||||
|
cp mod-list.json_$modlist mod-list.json_$save
|
||||||
#Check if a modlist exists for that save
|
#Check if a modlist exists for that save
|
||||||
if test -s mod-list.json_$save ; then
|
elif test -s mod-list.json_$save ; then
|
||||||
modlist=$save
|
modlist=$save
|
||||||
else
|
else
|
||||||
#Otherwise, prompt to load another modlist
|
#Otherwise, prompt to load another modlist
|
||||||
modlist=$(ls -t mod-list.json_* | cut -d "_" -f 2- | dmenu -p "No mod list found for savegame $save. Select mod list from available: ")
|
modlist=$(ls -t mod-list.json_* | cut -d "_" -f 2- | dmenu -p "No mod list found for savegame \"$save\". Select mod list from available: ")
|
||||||
|
|
||||||
test $? -ne 0 && echo "No modlist selected" && exit 1
|
test $? -ne 0 && echo "No modlist selected" && exit 1
|
||||||
|
|
||||||
#And prompt to save it for later
|
#And prompt to save it for later
|
||||||
echo -e "yes\nno" | dmenu -p "Save selected modlist for savegame $save ?" | grep "yes" && cp mod-list.json_$modlist mod-list.json_$save && modlist=$save
|
echo -e "yes\nno" | dmenu -p "Save selected modlist for savegame $save ?" | grep -q "yes" && cp mod-list.json_$modlist mod-list.json_$save && modlist=$save
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Link that modlist to the file read by factorio
|
#Link that modlist to the file read by factorio
|
||||||
|
Loading…
Reference in New Issue
Block a user