基于批处理脚本文本的游戏输入崩溃了吗?

基于批处理脚本文本的游戏输入崩溃了吗?

我正在使用批处理脚本编写一个基于文本的游戏,我将其编码为特定输入会导致特定的事情,但是当我在测试并输入我知道应该起作用的命令之一时,整个游戏就崩溃了,我不知道为什么。我是不是漏掉了括号?我拼错了命令吗?

我的代码:

@echo off
title [test]
color 0A
if "%1" neq "" (goto %1)

goto Menu

set circuton=false
set hatchopen=false
set keyhave=false
set wirefixed=false
set pliershave=false
set boxmoved=false
set boxhave=false
set circutpuzzle=false
set dooropen=false

:HelpCommands
echo The following are the commands able to be used. None are case sensitive.
echo TurnL - Turns left
echo TurnR - Turns right
echo Take_[item]- Takes an item if it is available.
echo Use_[item]- Prompts the question of how you want to use an item if you have it
echo Look_[thing]- Focuses in on one thing in the current environment. Is used the same as examine
echo Move_[object]- Moves an object. Is also used to open things. As in Move_door to open a door.
echo Return- Returns to previous area when looking at specific objects
echo FOR ANY MULTI WORD INPUT, ONLY USE UNDERSCORE AND NEVER SPACE
if %direction%==front goto Front
if %direction%==left goto Left
if %direction%==back goto Back
if %direction%==right goto Right
if %direction%==menu goto Menu

:Menu
cls
set direction=menu
echo THE ROOM
echo Please open a BROWSER window and enter GUEST MODE so the game may load any necessary IMAGES.
echo 1. START
echo 2. CREDITS
echo 3. EXIT
set /p answer=Type the number of your option and press enter :
if %answer%==1 (
    goto Start_1
) else if %answer%==2 (
    goto Credits
) else if %answer%==3 (
    goto Exit
) else if /I %answer%==GAME (
    start "" https://hempuli.itch.io/grey-room
    goto Menu
) else (
    goto ErrorInvalid
)

:Exit
cls
echo Are you sure you want to exit?
set /p answer=y/n
if /I %answer%==y exit /b
if /I %answer%==n goto Menu
goto Menu

:Credits
cls
echo Credits
echo -----
echo Thank you for playing THE ROOM by SYSTEMSD
echo Based directly on the game Grey Room by Hempuli in 2008
echo Find that on Hempuli's Itch.io page or by inputting GAME in the Menu.
pause
goto Menu

:Start_1
cls
echo You have found yourself in a square room
echo There are 4 walls, a floor and a ceiling, but only the walls will be important
echo That and the things that are on them.
echo Anything important will be capitalized in the descriptions.
goto Front

:Front
set direction=front
echo You are currently facing FORWARD in the room.
echo In front of you is a CIRCUTBOX on the LEFT SIDE OF THE WALL and a DOOR on the RIGHT SIDE with a KEYPAD to the LEFT of it
echo The CIRCUTBOX has a WIRE coming out of it that runs along the top of the wall, connected to something in the BACK of the room.
echo The door has an EIGHT on it.

:FrontPrompt
set /p answer=You are facing FORWARD. What do you do?
if /I %answer%==TurnL (
    goto Left
) else if /I %answer%==TurnR (
    goto Right
) else if /I %answer%==Look_Keypad (
    goto Keypad
) else if /I %answer%==Look_Circutbox (
    goto FrontCircut
) else if /I %answer%==Move_Door (
    goto Door
) else (
    goto ErrorInvalid
)

:Keypad
echo A keypad with the numbers ONE THROUGH NINE on it and, an OK button at the bottom.
goto KeypadPrompt

:KeypadPrompt
if %circutpuzzle%==false echo The power doesnt work
set /p answer=What number do you input before pressing OK?
if %answer%==582436719 (
    echo You hear a click 
    pause
    goto FrontPrompt
)
if /I %answer%==Return goto FrontPrompt
if %answer% NOT 582436719 (
    echo Nothing happens.
    pause
    goto FrontPrompt
)

:FrontCircut
echo Inside the CIRCUTBOX is a LEVER. On the inside of the door are tally marks adding up to FIVE
set /p answer=What do you do?
if /I %answer%==Return (
    goto FrontPrompt
) else if /I %answer%==Move_Lever (
    if %circuton%==false (
        echo You flip the switch
        set circuton=true
        goto FrontPrompt
    )
    if %circuton%==true (
        echo You flip the switch
        set circuton=false
        goto Frontprompt
    )
) else (
    goto ErrorInvalid
)

:Door
if %dooropen%==true goto congrats
if %dooropen%==false echo The door wont open.
pause
goto FrontPrompt

:Left
set direction=left
echo You are currently facing LEFT in the room.
echo In front of you is a BOX on the floor on the RIGHT SIDE OF YOUR VIEW and a CUPBOARD on the LEFT SIDE OF THE WALL.
echo The BOX has a SEVEN on it
if pliershave=false (
    goto LeftPrompt
) ELSE IF pliershave=true (
    echo The letter A is written in the back of the CUPBOARD
)
goto LeftPrompt

:LeftPrompt
set /p answer=You are facing LEFT. What do you do?
if /I %answer%==TurnL (
    goto Back
) else if /I %answer%==TurnR (
    goto Front
) else if /I %answer%==Look_Box (
    echo The box has a SEVEN written on it. You can pick it up.
    goto Leftprompt
) else if /I %answer%==Take_Box (
    if boxhave=true (
        echo You already have the BOX.
        goto LeftPrompt
    )
    if boxhave=false (
        echo You take the BOX
        echo On the floor underneath the BOX is a KEY.
        set boxhave=true
        goto LeftPrompt
    )
) else if /I %answer%==Look_Cupboard (
    echo There's a closed CUPBOARD. Try OPENING it (Move_Cupboard).
) else if /I %answer%==Move_Cupboard (
    if %pliershave%==false echo You open the cupboard and see a pair of PLIERS.
    if %pliershave%==true echo You see the letter A written on the back of the CUPBOARD.
    goto LeftPrompt
) else if (
if /i %answer%==Take_Pliers (
    if %pliershave%==true echo You already have the PLIERS.
    if %pliershave%==false (
        echo You take the PLIERS
        echo You see the letter A written on the back of the CUPBOARD.
        set pliershave=true
    )
    goto LeftPrompt
) else if /I %answer%==Take_Key (
    if %keyhave%==true echo You already have the KEY
    if %hatchopen%==true (
        echo The KEY has already been used.
        goto LeftPrompt
    )
    if %keyhave%==false (
        echo You take the KEY
        set keyhave=true
    )
    goto LeftPrompt
) else (
    goto ErrorInvalid
)
goto LeftPrompt

:Right
set direction=right
echo You are currently facing RIGHT in the room.
echo Running along the top of the wall is a WIRE that comes from the FRONT of the room and runs to something in the BACK
if %wirefixed%==false echo The WIRE is BROKEN in the middle.
if %hatchopen%==false echo There is a CLOSED HATCH on the LEFT SIDE of the wall with a KEYHOLE on it.
if %hatchopen%==true echo There is an OPEN HATCH on the LEFT SIDE of the wall with TWO pieces of PAPER inside it. (Paper1, Paper2)
echo On the RIGHT SIDE of the room is some sort of SIGIL.
goto RightPrompt

:RightPrompt
set /p answer=You are facing RIGHT. What do you do?
if /I %answer%==TurnL (
    goto Front
) else if /I %answer%==TurnR ( 
    goto Back
) else if /I %answer%==Look_Sigil (
    echo The SIGIL on the wall looks like the number FOUR surrounded by a circle.
) else if /I %answer%==Look_Wire (
    echo The WIRE is BROKEN in the middle. If only you had some way to BEND the ends back together.
) else if /I %answer%==Use_Box(
    if %boxmoved%==true (
        echo The BOX has already been placed down.
        goto RightPrompt
    if %boxhave%==false (
        echo You do not have the BOX.
        goto RightPrompt
    if %boxhave%==true (
        if %boxmoved%==true (
            goto RightPrompt
        )
    if %boxmoved%==false (
        echo You place the BOX underneath the WIRE so you have somewhere to stand.
        echo You can still TAKE the BOX if you need it again.
        set boxmoved=true
    )
) else if /I %answer%==Use_Pliers (
    if %wirefixed%==true (
        echo The wires are fixed. You dont need to do anything else with them.
        goto RightPrompt
    if %boxmoved%==false (
        echo You cant reach the WIRE. If only you had something to STAND on.
        goto RightPrompt
    if %pliershave%==false ()
    if %boxmoved%==true (
        if %pliershave%==true (
            echo You stand on the BOX and use the PLIERS to fix the WIRE
            set wirefixed=true
        )
    goto RightPrompt
) else (
    goto ErrorInvalid
)


:Back
set direction=back

:BackPrompt

:ErrorInvalid
echo Whoops! You input an invalid command. Try again!
pause
if %direction%==menu goto Menu
if %direction%==front goto FrontPrompt
if %direction%==left goto LeftPrompt
if %direction%==right goto RightPrompt
if %direction%==back goto BackPrompt

:UNFINISHED
cls
echo Whoops! Looks like you entered an option with an unfinished endpoint!
echo Sorry about that!
echo Hopefully its fixed by the next time you play!
pause
goto Menu

相关内容