Author Topic: .bat Code Not Working!  (Read 536 times)

Code: [Select]
@echo off
title Text Adventure
color 0c
echo     ------------ TEXT ADVENTURE ------------
echo.
echo What do you want to do?
echo Enter 1 to begin
echo Enter 2 to exit
set /p var=Type Here:
if %var%==1 then goto start
if %var%==2 then goto exit

:start
cls
echo You wake up in a desert... it is hot and dry here.
echo You see water in the distance, and a man drinking it.
echo You have a map
echo Enter 1 to go to the water.
echo Enter 2 to walk until you find help.
set /p %fn%
if %fn%==1 then goto waterdesert
if %fn%==2 then goto walkdesert
goto start
:exit


goto exit
:waterdesert
echo As you walk towards it, the water fades away.
echo The water must've been a mirage!
echo What do you do?
echo Enter 1 to walk until you are out of the desert
echo Enter 2 to look for help.
set /p %fn2%
if %fn2%==1 then goto walkdesert
if %fn2%==2 then goto helpdesert
goto waterdesert
:walkdesert
echo You walk for 1 hour...
echo You have seen nothing but sand and cacti for MILES.
echo Your stomach rumbles...
echo What do you do?
echo Enter 1 to collect sand and make a fortress.
echo Enter 2 to use cacti as food
set /p %fn3%
if %fn3%==1 then goto sandfort
if %fn3%==2 then goto cactieat
goto waterdesert
I am working on a text adventure and need help, please, someone fix it!
The start up menu commands do not work properly.
Thanks in advance!
« Last Edit: March 14, 2012, 07:32:08 AM by comedy101experiments »

This looks like .bat "coding"
Edit: It is, how you mistook this for C++ I will never know

if %fn2%==1 then goto walkdesert
if %fn2%==2 then goto helpdesert



if %fn2%==1 goto walkdesert
if %fn2%==2 goto helpdesert

hurr

AHAHAHAHAHAH, that is no where near the realm of C++. My sides.

This looks like .bat "coding"
Edit: It is, how you mistook this for C++ I will never know
I searched for how to make a text adventure in C++ and a tutorial came up with a similar code to this one!
if %fn2%==1 then goto walkdesert
if %fn2%==2 then goto helpdesert



if %fn2%==1 goto walkdesert
if %fn2%==2 goto helpdesert

hurr
OOPS, sorry lol

Edit:
Okay, so I tried that, but my code still fails!  Can someone help?
Code: [Select]
@echo off
title Text Adventure
color 0c
echo    ------------ TEXT ADVENTURE ------------
echo.
echo What do you want to do?
echo Enter 1 to begin
echo Enter 2 to exit
set /p var=Type Here:
if %var%== 1 goto start
if %var%== 2 goto exit

:start
cls
echo You wake up in a desert... it is hot and dry here.
echo You see water in the distance, and a man drinking it.
echo You have a map
echo Enter 1 to go to the water.
echo Enter 2 to walk until you find help.
set /p %fn%
if %fn%==1 goto waterdesert
if %fn%==2 goto walkdesert
goto start
:exit


goto exit
:waterdesert
echo As you walk towards it, the water fades away.
echo The water must've been a mirage!
echo What do you do?
echo Enter 1 to walk until you are out of the desert
echo Enter 2 to look for help.
set /p %fn2%
if %fn2%==1 goto walkdesert
if %fn2%==2 goto helpdesert
goto waterdesert
:walkdesert
echo You walk for 1 hour...
echo You have seen nothing but sand and cacti for MILES.
echo Your stomach rumbles...
echo What do you do?
echo Enter 1 to collect sand and make a fortress.
echo Enter 2 to use cacti as food
set /p %fn3%
if %fn3%==1 goto sandfort
if %fn3%==2 goto cactieat
goto walkdesert
« Last Edit: March 14, 2012, 03:53:00 PM by comedy101experiments »

Line 9:
set /p var=Type Here:

everywhere else:
set /p %fn3%

do the same as line 9 everywhere and it will WAIT for an entry instead of just running through it.
oh and you have infinite loops loving everywhere

fixed:
Code: [Select]
@echo off
title Text Adventure
color 0c
echo    ------------ TEXT ADVENTURE ------------
echo.
echo What do you want to do?
echo Enter 1 to begin
echo Enter 2 to exit
set /p var=Type Here:
if %var% == 1 goto start
if %var% == 2 goto exit
pause

:start
cls
echo You wake up in a desert... it is hot and dry here.
echo You see water in the distance, and a man drinking it.
echo You have a map
echo Enter 1 to go to the water.
echo Enter 2 to walk until you find help.
set /p fn=Type Here:
if %fn% == 1 goto waterdesert
if %fn% == 2 goto walkdesert
pause

:waterdesert
cls
echo As you walk towards it, the water fades away.
echo The water must've been a mirage!
echo What do you do?
echo Enter 1 to walk until you are out of the desert
echo Enter 2 to look for help.
set /p fn=Type Here:
if %fn% == 1 goto walkdesert
if %fn% == 2 goto helpdesert
pause

:walkdesert
cls
echo You walk for 1 hour...
echo You have seen nothing but sand and cacti for MILES.
echo Your stomach rumbles...
echo What do you do?
echo Enter 1 to collect sand and make a fortress.
echo Enter 2 to use cacti as food
set /p fn=Type Here:
if %fn% == 1 goto sandfort
if %fn% == 2 goto cactieat
pause

:exit
exit
note the fact i used the same variable for choice everywhere instead of making a new one each time
« Last Edit: March 14, 2012, 04:23:23 PM by Lugnut1206 »