当你进入用户输入部分时,无论我输入什么(桌子、火、门),它总是进入壁炉。我的 if 语法有问题吗?
@echo off
color C
title RG Text Game
echo -------------------------------------------------
echo Welcome to the Game!
echo.
echo -------------------------------------------------
echo.
pause
echo.
echo Blah bah blah story story
echo What do you want to do?
echo Choices: fire/desk/door
set /p choice=
if %choice%=="fire" GOTO fireplace
if %choice%=="desk" GOTO desk
if %choice%=="door" GOTO door
:fireplace
echo.
echo You come to the fireplace.
echo.
pause
:desk
echo.
echo You go to the desk.
echo.
:door
echo.
echo You go to the door.
echo.
双引号%choice%
或它不会等于:desk
不等于"desk"
。
并Label
用goto:eof
或退出您的块exit/b
。
使用/i
switch withIF
这样你也可以使用DESK
或DesK
if /i "%choice%"=="fire" GOTO fireplace
if /i "%choice%"=="desk" GOTO desk
if /i "%choice%"=="door" GOTO door
goto:error
:fireplace
echo.
echo You come to the fireplace.
echo.
pause
exit/b
:desk
echo.
echo You go to the desk.
echo.
exit/b
:door
echo.
echo You go to the door.
echo.
exit/b
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句