Skip to content

Instantly share code, notes, and snippets.

@sergeylukin
Created October 13, 2015 04:27
Show Gist options
  • Save sergeylukin/4a210691c65358ccdb02 to your computer and use it in GitHub Desktop.
Save sergeylukin/4a210691c65358ccdb02 to your computer and use it in GitHub Desktop.
Save and load progress in "This War of Mine" video game
#!/bin/bash
# Copyright (c) 2015 gruberator
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by the gruberator. The name of the
# gruberator may not be used to endorse or promote products derived
# from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# This script's purpose is to compensate lack of intro tutorial in the game and to allow
# you to try different actions without fear of having to start all over again
# Please note that this script is not recommended for players who are familiar
# with game controls already
# This is path to This War of Mine save folder, if this script does not work for you change it to correct folder
twom_save_folder="/PATH/TO/Steam/userdata/PROFILE/282070/remote"
# This is folder where saves will be copied
saveFolder=~/twom_save
# This is default folder where save files will be stored and from where
# save files will be restored if no store name will be given
defaultFolder='default'
# Remove trailing slashes from paths
# It allows supporting paths with and without
# trailing slash because by removing trailing
# slash we "normalize" the path assuming
# that it doesn't have one after this
# normalization
twom_save_folder=${twom_save_folder%/}
saveFolder=${saveFolder%/}
copyFolder=$saveFolder
if [ ! -d "$saveFolder" ]; then
mkdir $saveFolder
fi
if (( $# > 0 )); then
if [ "$1" = "-s" ]; then
if (( $# > 1 )); then
copyFolder=$copyFolder/$2
else
copyFolder=$copyFolder/$defaultFolder
fi
rm -rf $copyFolder
cp -r "$twom_save_folder" $copyFolder
echo 'This War of Mine saved to folder ' $copyFolder
exit
fi
if [ "$1" = "-l" ]; then
if (( $# > 1 )); then
copyFolder=$copyFolder/$2
else
copyFolder=$copyFolder/$defaultFolder
fi
rm -rf "$twom_save_folder"
cp -r $copyFolder "$twom_save_folder"
echo 'This War of Mine save loaded from folder ' $copyFolder
exit
fi
if [ "$1" = "-r" ]; then
if (( $# > 1 )); then
rmf=$saveFolder/$2
echo $rmf
rm -r $rmf
echo 'Save ' $2 ' removed'
exit
fi
fi
echo "twom is script to save/load and list saves made in This War of Mine usage:"
echo "-s [savename] saves game to savename (copies directory with saved game state)"
echo "-l [savename] loads savegame (moves copied game state to the game save state directory)"
echo "-r [savename] removes savegame"
echo "no args lists folder with saves (this is your home/twom_save/ dir)"
echo "NOTICE! if this script does not work try setting path to the steam directory with TWOM saves which has name twom_save_folder in this script"
echo ""
fi
echo "List of This War of Mine saved games:"
ls -l $saveFolder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment