Launcher script for ADOM

As promised, here’s a launcher script that will automatically back up and restore ADOM save games.

To use it simply copy paste everything in green into a text editor and then save it into the same directory that you put ADOM into. For example, let’s say that I put ADOM into a folder on my desktop: “~/Desktop/adom_folder” then I’d save this script as “~/Desktop/adom_folder/launch_adom.sh”.

One more thing, set the permissions of the script file so that it can run. Do this by opening up a terminal and using chmod on it. For example:

chmod ugo+xxx ~/Desktop/adom_folder/launch_adom.sh

After that simply run ADOM by running the script. If you get a message that says something like: “cp: cannot stat `/home/doctorme/.adom.data/savedg/*’: No such file or directory” that just means that the script couldn’t find what it was looking for. No files will be harmed unless you backup over your own saves.

#!/bin/sh
# set some variables to make life easy
MY_SAVES_DIR="$HOME/.adom.data/my_saves"
ADOM_SAVE_DIR="$HOME/.adom.data/savedg"
# double check those variables
# delete the "#" if you want to see these printed out
#echo "MY_SAVES_DIR=$MY_SAVES_DIR"
#echo "ADOM_SAVE_DIR=$ADOM_SAVE_DIR"

################################################################
# check to be sure my_saves exists before attempting to copy
if [ -d $MY_SAVES_DIR ]; then
        echo "$MY_SAVES_DIR already exists, moving on."
    else
        # if it doesn't exist then we'll create it
        echo "creating $MY_SAVES_DIR to put saves into."
        mkdir $MY_SAVES_DIR
fi

################################################################
# ask if we should back up saves into our own safe place
YES_STR="y"
CMND="empty"
echo "backup saves? (y/n)"
read CMND
if [ $CMND = $YES_STR ]; then
        cp $ADOM_SAVE_DIR\/* $MY_SAVES_DIR\/
        echo "Saves are saved."
    else
        echo "Saves NOT saved."
fi

################################################################
# now launch adom
echo "Starting ADOM..."
./adom

################################################################
# now ask if we should restore saves (say, if you died)
YES_STR="y"
CMND="empty"
echo "Restore saves? (y/n)"
read CMND
if [ $CMND = $YES_STR ]; then
        cp $MY_SAVES_DIR\/* $ADOM_SAVE_DIR\/
    else
        echo "Saves not restored."
fi

About this entry