为什么我的批处理程序会一直崩溃?

时间:2016-03-14 02:44:44

标签: batch-file

我做了一个(迄今为止571行)冒险游戏,但每当我在这个字符串中选择“3”时,它就会崩溃。就像,它只是立即关闭窗口。我唯一的想法是它可能是如何设置选择1,但任何帮助都会受到赞赏。

:stayinbed
cls
echo You slowly get out of bed, the monster watches you.
echo.
echo 1) Make a run for it.
echo 2) Begin to teach it how to speak, be nice to it.
echo 3) Get a kitchen knife.
echo.
:loop11
set /p Choice=Choose Now: 
if "%Choice%"=="1" 
cls
gotorun4life3
if "%Choice%"=="2" goto justbenice
if "%Choice%"=="3" goto kitchen
goto loop11

:justbenice
cls
echo You spend the next couple years of your life teaching the creature about life.
echo He is like a child to you, a very disgusting child that is not allowed in public.
echo.
pause
cls
echo You spend decades with him, researching all fields of science.
echo But alas, all good things come to an end.
echo Eventually you contract cancer and die, the monster at your bedside.
pause
goto end1

:kitchen
cls
echo You begin to slowly walk towards your cabinet.
timeout /t 2 /nobreak >nul
echo It watches you, but you keep walking towards the cabinet.
timeout /t 2 /nobreak >nul
echo You arrive at the cabinet and grab a knife.
echo.
echo 1) Screw it, just run.
echo 2) Kill the abomination.
echo.
:loop12
set /p Choice=Choose Now: 
if "%Choice%"=="1" 
cls
goto run4life3
if "%Choice%"=="2" goto killit
goto loop12


:killit
cls
echo You grasp the knife in your hand and look right at the creature.
timeout /t 1 /nobreak >nul
echo You run towards it.
timeout /t 1 /nobreak >nul
echo You stab it in the back of the head.
call :colorEcho 0a "RAAAAUUUGGGHHH"
echo.
echo It falls flat on the ground with a thud.
goto end1

1 个答案:

答案 0 :(得分:0)

问题在于:

if "%Choice%"=="1" 
cls
gotorun4life3

应该是:

if "%Choice%"=="1" cls & goto run4life3

if "%Choice%"=="1" (
    cls
    goto run4life3
)

当它到达gotorun4life3行时,它会崩溃,因为它无法解析此命令。