So I'm trying to make a dungeon and I want to have 2 different responses when I enter the one room but I thats as far as I can get. How do I get 2 different outcomes from 1 file?
So when you open a file for the first time I want it to display a specific content, when you return to that file and reopen it I want it to display a different content. However, both contents are in the same file. Just want one content to read for the first visit and the second content to read upon repeat visits.
Is it possible to have two separate outputs to one file. Example, if you run the file below for the first time you get the response of "sup sup" and if you were to run it a second time you would get the "no no" response. This is just an example but thats what I'm trying to get at. So how exactly can I manage that?
this=1
if [ "$this"=="1" ]; then
echo "sup sup"
let "this=$this - 1"
fi
if [ "$this"=="0" ]; then
echo "no no"
fi
$HOME
when you run it for the first time, e.g. in one line :[ -f /$HOME/.dungeonscriptwasrun ] && echo "no no" || echo "sup sup"; touch /$HOME/.dungeonscriptwasrun
. Note however that this will only work as intended if you remove that file when the application is closed (so that on subsequent runs, your script starts fresh). – don_crissti Nov 26 '14 at 18:55GAME=Start while [ "$GAME"=="Start" ] do sh dungeon1 (inside this file I will have two outputs I want to be displayed such as: when you open the file for the first time you would get the content "Sup, Sup/ Would you like to continue", and then the second content would be "You're back where you started". So I want the "You're back where you started" when you return to dungeon1. so continuing on in the dungeon.sh) read RESPONSE case $RESPONSE in "Continue") sh dungeon2;; "Return") sh dungeon1;
– Ash Ly Nov 26 '14 at 19:11if [ "$this" == "1" ]
(or ratherif [ "$this" -eq 1 ]
if you want a numeric comparison rather than a string comparison). – Gilles 'SO- stop being evil' Nov 26 '14 at 23:34