转到错误.bat

时间:2013-10-29 00:15:38

标签: windows batch-file cmd

我正在尝试批量制作一个简单的游戏,当我尝试从1:2:3或:4时,我不断收到goto错误。我不知道它有什么问题。请告诉我这个问题。谢谢!附:我是新来的。

:start
@echo off 
color a
echo Adventue V2 
echo 10/28/2013
pause
echo Name?
set /p name=
echo Hello %name%! Would you like to start (y/n)
set /p start=
if %start% == y goto 1
if %start% == Y goto 1
if %start% == n goto start
if %start% == N goto start

:1
echo Let us Begin...
echo The year is 1673 and you are living on a small farm. What do you do?
echo 1)Feed Chicken 2)Feed Cow 3)Fetch Water
set /p 1=
if %1% == 1 goto 2
if %1% == 2 goto 3
if %1% == 3 goto 4

:2
echo You go to the chicken pen and find one of your chickens has been killed by a fox. What do you do?
echo 1)Look For The Fox 2)Tell Your Father 3)Tell Your Mother
set /p 2=
if %2% == 1 goto 5
if %2% == 2 goto 6
if %2% == 3 goto 7

:3
echo You feed The cows and you find a coin purse. What do you do?
echo 1)Look In It 2)Leave It
set /p 3=
if %3% == 1 goto 8
if %3% == 2 goto 9

:4
echo You got to the well to fetch water but the well is empty. What do you do?
echo 1)Crawl Into It 2)Tell Your Parents
set /p 4=
if %4% == 1 goto 10
if %4% == 2 goto 11

1 个答案:

答案 0 :(得分:2)

我认为是因为你的%number%导致了这个问题。将您的变量更改为%variablename%,这应该有效。

例如,而不是:

:1
echo Let us Begin...
echo The year is 1673 and you are living on a small farm. What do you do?
echo 1)Feed Chicken 2)Feed Cow 3)Fetch Water
set /p 1=
if %1% == 1 goto 2
if %1% == 2 goto 3
if %1% == 3 goto 4

将其更改为:

:1
echo Let us Begin...
echo The year is 1673 and you are living on a small farm. What do you do?
echo 1)Feed Chicken 2)Feed Cow 3)Fetch Water
set /p q1=
if %q1% == 1 goto 2
if %q1% == 2 goto 3
if %q1% == 3 goto 4