Last active
February 24, 2024 02:39
-
-
Save mpentler/ea07f8b37439cb6c1d7deca7ae764b58 to your computer and use it in GitHub Desktop.
Script for running Zork as multiple possible users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export HOME="/home/pi" | |
export TERM="linux" | |
read CALL | |
CALL=$(echo "$CALL" | tr -d '\r') | |
mkdir -p "/home/pi/zork/nodesaves/$CALL" | |
echo "Hello $CALL! Do you wish to load a saved game? [y/N]" | |
read REPLY | |
REPLY=$(echo "$REPLY" | tr -d '\r') | |
echo | |
case "$REPLY" in | |
y|Y ) echo "Enter filename to load"; read FILENAME; FILENAME=$(echo "$FILENAME" | tr -d '\r'); echo "Loading $FILENAME"; /usr/games/dfrotz -R /home/pi/zork/nodesaves/$CALL -L /home/pi/zork/nodesaves/$CALL/$FILENAME /home/pi/zork/DATA/ZORK1.DAT;; | |
* ) echo "Starting a new game..." ;/usr/games/dfrotz -R /home/pi/zork/nodesaves/$CALL /home/pi/zork/DATA/ZORK1.DAT;; | |
esac | |
echo "Cleaning up filenames (removing control characters)" | |
cd /home/pi/zork/nodesaves/$CALL/ | |
for file in *; do mv "$file" $(echo "$file" | sed -e 's/[^A-Za-z0-9._-]//g'); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment