Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理编程:为什么我的选择系统不起作用_Batch File - Fatal编程技术网

Batch file 批处理编程:为什么我的选择系统不起作用

Batch file 批处理编程:为什么我的选择系统不起作用,batch-file,Batch File,我正在制作一个批量游戏,在你回答第一个问题之前一直有效(choice1Scene1) set/p%playerChoice1Scene1%=尝试设置playerChoice1Scene1的当前内容。移除%s以设置变量playerChoice1Scene1 请只发布显示您的问题所需的代码部分,以及代码应该做什么和实际做什么的描述。除了Magoo所说的,还有!==符号?没有这样的接线员。如果“%opt%”NEQ“S”,则需要;如果不是“%opt%”,则需要。对于不区分大小写的测试,if/i。键入if

我正在制作一个批量游戏,在你回答第一个问题之前一直有效(choice1Scene1)


set/p%playerChoice1Scene1%=
尝试设置playerChoice1Scene1的当前内容。移除
%
s以设置变量
playerChoice1Scene1


请只发布显示您的问题所需的代码部分,以及代码应该做什么和实际做什么的描述。

除了Magoo所说的,还有
!==符号?没有这样的接线员。如果“%opt%”NEQ“S”
,则需要
;如果不是“%opt%”,则需要
。对于不区分大小写的测试,
if/i
。键入
if/?`以获取帮助


其次,
choice
命令更容易用于您的目的。键入
choice/?
以获取帮助。

在提问之前,请考虑阅读帮助文件以获取命令。在命令提示下,可以键入命令名,后跟正斜杠和问号。示例:
如果/?
@echo off
title RPG
color 0C

:top

echo ***************************************************************************

echo                     ~Welcome To Wild West Ranger~

echo ***************************************************************************

echo.

echo.

echo                  please type answers exactly as they appear

echo.

echo.

echo                     ~Enter S To Begin Your New Life~

echo.

echo.

echo.

set /p opt=

if %opt%==S GOTO name

if %opt%!==!S GOTO top

if %opt%==s GOTO name

if %opt%!==!s GOTO top



pause

cls



:name

echo ***************************************************************************

echo                        What Will You Be Called?

echo ***************************************************************************



set /p playerName=

set playerHealth=100HP

echo.

echo.

echo.

echo.

echo.



cls



echo Your name is %playerName%?

echo Key:

echo [1] Yes

echo [2] Redo

echo [e] Exit

echo.



set /p playerNameChoice=

if %playerNameChoice%==1 goto nameConfirmed

if %playerNameChoice%==2 goto name

if %playerNameChoice%==e goto exit



:nameConfirmed

echo WELCOME %playerName% TO THE WEST


echo.

echo.

cls

goto gameStart











:gameStart

echo.

echo [Health %playerHealth%]

echo You wake up on the ground outside an old wooden barn...

echo What will you do?

echo.

echo.



echo [1] Get up and walk inside the barn

echo [2] Get up and look for others

echo [3] Go back to sleep





set /p %playerChoice1Scene1%=





if %playerChoice1Scene1%==1 goto choice1'2Scene1

if %playerChoice1Scene1%==2 goto choice2Scene1

if %playerChoice1Scene1%==3 goto choice1Scene1

if %playerChoice1Scene1%!==!1 goto gameStart

if %playerChoice1Scene1%!==!2 goto gameStart

if %playerChoice1Scene1%!==!3 goto gameStart













:choice1'2Scene1

echo.

echo [Health %playerHealth%]

echo You walk around around the barn and enter through two big wooden doors.

echo Inside you see a table with two choice weapons on it...

echo.

echo.



echo [Spanish Pistol] Fast Fire, 15 Bullets, Not As Accurate

echo [Long-Barreled Western Pistol] Medium Fire, 10 Bullets, Very Accurate



set /p %playerChoice1Scene1%=



if %playerChoice1Scene1%==Spanish Pistol goto choice1'3Scene1

if %playerChoice1Scene1%==Long-Barreled Western Pistol goto choice1'3Scene1

if %playerChoice1Scene1%!==!Spanish Pistol goto choice1'2Scene1

if %playerChoice1'2Scene1%!==!Long-Barreled Western Pistol goto choice1'2Scene1









:exit
cls
echo ***************************************************************************
echo.
echo                 Thanks For Playing Wild West Ranger
echo.
echo ***************************************************************************
pause
exit