Solved Batch file code not working

October 30, 2015 at 11:06:29
Specs: Windows 10
I've been trying to get into batch programming and I made this choose your own adventure type script, but it won't work, can anyone help?


@echo off
title Choose your adventure
color 0a

::#################
:one
echo There are zombies everywhere, what do you do!?!?
echo.
echo.
echo 1) Run
echo 2) Kill yourself
echo 3) Find your family
echo 4) Find your friends
set /p ch1 =
if not defined ch1(
goto one
)
if %ch1%==1 goto Run
if %ch1%==2 goto Suicide
if %ch1%==3 goto Family
if %ch1%==4 goto Friends
echo Invalid
goto one
::###################
cls
:Run
echo You run right in to the mouth of your zombified ex-girlfriend, you're dead.
echo.
echo.
echo Try Again?
echo.
echo.
set /p ynrestart=">>"
if %ynrestart%==yes goto one
if %ynrestart%==no goto lulz
::##################
cls
:Suicide
echo Well I guess you won, there aren't any zombies in the afterlife. Congratz!
echo.
echo.
echo.
goto one
::#################
cls
:Family
echo You find your family hiding inside of the bomb shelter in your house.
echo They greet you with smiles and tears of joy. You need to create a plan.
echo Your parents suggest scavenging once everyday and just hide in the shelter
echo for the rest of the apocalypse.
echo Your brother suggests that we head out and kill the all the zombies.
echo Finally your sister suggests that we head out towards the country side
echo and see if there are any survivors left.
echo.
echo.
set /p familych="Who do you agree with?"
if %familych%== parents goto parents
if %familych%== brother goto brother
if %familych%== sister goto sister
::##################
cls
:parents
echo The years pass by as your family and you live this boring life of hiding.
echo After 5 years your family has gone insane without much to do in the bombshelter
echo 20 years pass and your parents die. Your used to be little brother is now a full
echo grown adult. Everyone dies of natural causes. I guess you survived but half
echo of your life was now spent sitting down doing nothing.
goto one
::#########################
cls
:brother
echo Seems fun so everyone goes out and gives the zombies a piece of their mind.
echo But the fun soon ends when after 5 minutes everyone gets bitten. It sounded
echo fun...
goto one
::#############################################################################
cls
:sister
echo You go out cautiously and head to the country side the screams of pain
echo are hard to get out of your head but you just have to deal with them.
echo You reach a farm house with a friendly family of survivors, do you
echo confront them?
set /p confrontyn=">>"
if %confrontyn%== yes goto confrontyes
if %confrontyn%== no goto confrontno
::############################



See More: Batch file code not working

Report •

#1
October 30, 2015 at 21:26:30
[1] strip out the clutter: title, color echo...

[2] say what it did; or didn't did

11:26 2015-10-31

=====================

M2 Get custom script or take private lessons


Report •

#2
October 31, 2015 at 09:02:23
What do you mean by, did or didn't did?

Report •

#3
October 31, 2015 at 18:25:38
✔ Best Answer
Whenever you use SET /P, (I've learned it hard), ALWAYS clear your variable, or else it will default to "old" outdated choices. f/e:
set x=
set /p x=input:

In other words, SET does not clear or alter the variable's value if the input is null - the var. retains its initial value. That may or may not be relevant to the problem, but as M2 pointed out, no one knows what the "failure issue" is with your script.


Report •
Related Solutions


Ask Question