Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 12608

Batch script text based game input crashes?

$
0
0

I'm coding a text based game using batch script, and I coded it so specific inputs lead to specific things, but when I'm testing and I input one of the commands that I know is supposed to work, the entire thing just crashes and I have no idea why. Am i missing parentheses somewhere? Did I misspell a command?

My code:

@echo offtitle [test]color 0Aif "%1" neq "" (goto %1)goto Menuset circuton=falseset hatchopen=falseset keyhave=falseset wirefixed=falseset pliershave=falseset boxmoved=falseset boxhave=falseset circutpuzzle=falseset dooropen=false:HelpCommandsecho The following are the commands able to be used. None are case sensitive.echo TurnL - Turns leftecho TurnR - Turns rightecho 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 itecho Look_[thing]- Focuses in on one thing in the current environment. Is used the same as examineecho 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 objectsecho FOR ANY MULTI WORD INPUT, ONLY USE UNDERSCORE AND NEVER SPACEif %direction%==front goto Frontif %direction%==left goto Leftif %direction%==back goto Backif %direction%==right goto Rightif %direction%==menu goto Menu:Menuclsset direction=menuecho THE ROOMecho Please open a BROWSER window and enter GUEST MODE so the game may load any necessary IMAGES.echo 1. STARTecho 2. CREDITSecho 3. EXITset /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):Exitclsecho Are you sure you want to exit?set /p answer=y/nif /I %answer%==y exit /bif /I %answer%==n goto Menugoto Menu:Creditsclsecho Creditsecho -----echo Thank you for playing THE ROOM by SYSTEMSDecho Based directly on the game Grey Room by Hempuli in 2008echo Find that on Hempuli's Itch.io page or by inputting GAME in the Menu.pausegoto Menu:Start_1clsecho You have found yourself in a square roomecho There are 4 walls, a floor and a ceiling, but only the walls will be importantecho That and the things that are on them.echo Anything important will be capitalized in the descriptions.goto Front:Frontset direction=frontecho 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 itecho 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.:FrontPromptset /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):Keypadecho A keypad with the numbers ONE THROUGH NINE on it and, an OK button at the bottom.goto KeypadPrompt:KeypadPromptif %circutpuzzle%==false echo The power doesnt workset /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 FrontPromptif %answer% NOT 582436719 (    echo Nothing happens.    pause    goto FrontPrompt):FrontCircutecho Inside the CIRCUTBOX is a LEVER. On the inside of the door are tally marks adding up to FIVEset /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):Doorif %dooropen%==true goto congratsif %dooropen%==false echo The door wont open.pausegoto FrontPrompt:Leftset direction=leftecho 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 itif pliershave=false (    goto LeftPrompt) ELSE IF pliershave=true (    echo The letter A is written in the back of the CUPBOARD)goto LeftPrompt:LeftPromptset /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:Rightset direction=rightecho 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 BACKif %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:RightPromptset /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):Backset direction=back:BackPrompt:ErrorInvalidecho Whoops! You input an invalid command. Try again!pauseif %direction%==menu goto Menuif %direction%==front goto FrontPromptif %direction%==left goto LeftPromptif %direction%==right goto RightPromptif %direction%==back goto BackPrompt:UNFINISHEDclsecho 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!pausegoto Menu

Viewing all articles
Browse latest Browse all 12608

Trending Articles