Batch file &引用&引用;在这个时候是出人意料的

Batch file &引用&引用;在这个时候是出人意料的,batch-file,Batch File,我正在一个批处理文件中编写我的第一个游戏,我不断地得到错误信息 “‘此时拍摄是意外的’”。“take”是我给变量“shotgun”赋值的。我想做的是,如果用户没有“拿起幕府将军”,它会让他们留在当前区域,但如果他们拿起它,它会将他们移动到其他“活动”区域 设置变量时,=字符的两边都不应该有空格,set/p command=将以名为%command%的变量结尾。同样地,将变量设置为take应该是“shotgun=take”而不是shotgun=take,这将%shotgun%设置为值take(带前

我正在一个批处理文件中编写我的第一个游戏,我不断地得到错误信息 “‘此时拍摄是意外的’”。“take”是我给变量“shotgun”赋值的。我想做的是,如果用户没有“拿起幕府将军”,它会让他们留在当前区域,但如果他们拿起它,它会将他们移动到其他“活动”区域


设置变量时,
=
字符的两边都不应该有空格,
set/p command=
将以名为
%command%
的变量结尾。同样地,将变量设置为take应该是
“shotgun=take”
而不是
shotgun=take
,这将
%shotgun%
设置为值
take
(带前导空格)。标签名称应该直接跟在
后面,没有空格,所以
:barn_right
不是
:barn_right
。当将
%shotgun%
设置为
take
时,使用
Set
not
Set/P
。通常我建议使用
Set/P“command=“
但是在这种情况下,我建议不要使用
Set/P
,而是使用
Choice
。如果要检查匹配项,请使用
=
而不是
=
,最好不要使用
eq

Echo(你进入谷仓时,它像外面一样阴暗潮湿。
回音(
你想知道这个谷仓里有没有什么有用的东西。
回音(
Echo(你应该检查楼梯下面的左边还是右边?
回音(
选择/C LR
如果错误2级转到仓库,对吗
:谷仓左死
如果/I“%shotgun%”==“take”转到谷仓\u离开\u现场
回声(你听到右边地板吱吱作响,一个受感染的人向你扑来,把你撕成碎片。
回音(
你死了
回音(
超时-1/NoBreak
:谷仓还活着
回声(你听到右边地板吱吱作响,你用猎枪杀死向你扑来的感染者!
回音(
Echo(你决定去另一栋楼,是去小屋还是去房子?
回响
选择/C HS
如果错误级别2转到shed
后藤之家酒店
:谷仓,对
回声(你在黑暗中看到一道闪光,它似乎是猎枪枪管钢上反射的月光。
回音(
你拿着猎枪。
回音(
设置“猎枪=射击”
Echo(你现在应该去房子、小屋,还是检查左边楼梯下面?
回音(
选择/左侧驾驶
如果错误级别为3,则转到shed_die
如果错误级别2,则转到house_die
去左边的楼梯
超时-1/NoBreak

通常情况下,我同意@Mofi的可能重复,正如您所看到的,有太多问题,单凭这一点无法解决他们的困境。
: barn

    echo. You enter the barn, it's creeky and it's dark, just as it is outside.
    echo.
    echo. You wonder if anything of use is in this barn.
    echo.
    echo. Should you check under the staircase to the left or to the right?
    echo.
    set /p command =
    echo.
    if %command% equ right goto barn_right
    if %command% equ left goto barn_left_die

        : barn_left_die
        if %shotgun% equ taken goto barn_left_live
        echo. You hear creeking in the floorboards to the right, an infected jumps at you tearing you into pieces.
        echo.
        echo. YOU ARE DEAD
        echo.
        pause

            : barn_left_live
            echo. You hear creeking in the floorboards to the right, you kill the infected that jumps at you with your shotgun!
            echo. You decide to go to a different building, do you go to the shed or house?
            echo.
            set /p command =
            echo.
            if %command% = shed goto shed
            if %command% = house goto house

        : barn_right
        echo. You see a glint in the dark, it appears to be the moon light reflecting off the steel of a shotgun barrel.
        echo.
        echo. You take the shotgun.
        echo.
        set /p shotgun = taken
        echo. Should you now go to the house, shed, or check underneath the left staircase?
        echo.
        set /p command =
        echo.
        if %command% = shed goto shed_die
        if %command% = house goto house_die
        if %command% = left goto left_staircase_die
        pause