lundi 24 avril 2017

Linux UBUNTU BASH - Goto a specific part of script

I'm making a random number guessing game, but I want it to last longer than one guess, when u guess wrong it adds one to ded. and repeats from a certain point (I'll add STARTHERE where it needs to start again). I know theres a command in Windows with:

:hello script goto hello.

But this doesn't work in Ubuntu Bash. Here's my script.

number=$(( (RANDOM % 100)  + 1 ))

# If The Guess is the same as the Number, it echoes.
echo "Oh! Hello. uhh, wanna play a game? Yes? No? hehe I won't let you 
cancel! >:D"
echo $number # Just for testing purposes
STARTHERE (This is not in the script)
read guess
if [ $guess = $number ];
then
echo "Cool! You won!"


# If the Guess is GREATER than the number, it will echo a ridiculous 
echo :p
elif [ $guess > $number ]
then
echo "WOW, WOW! KEEP IT A LITTLE LOWER PLEASE?! YOU'RE SHOOTING 
THROUGH THE SKY WITH THIS HIGH OF AN ANSWER!!! That said, I would like 
to go to space once! Don't you?!?"

# If the Guess is Less than the number, It will echo and think you are 
a mole... huh? Also, since when can computers question 
philosophy?!
elif [ $guess < $number ]
then
echo "Um... That's a bit too low... Are you fleeing undergound? 
Instead of space?? I don't get it... I'm a computer. So I cannot 
comprehend human feelings (yet). What is the theory of life??! WHAT IS 
life?!?!?!?"
fi

# Repeats it over and over and over and over and over and over and 
over and over and over and over and over and over and over and over 
and over and over again. until u ded and u lose. Or die of old age.
( & = 1 )
elif [ $guess =/= $number ]
then
ded=&((  (+ 1) ))

fi




Aucun commentaire:

Enregistrer un commentaire