Batch file 带有批处理代码的游戏不断崩溃

Batch file 带有批处理代码的游戏不断崩溃,batch-file,Batch File,我什么都试过了,我对编码很陌生,所以代码很简单,但我对到底是什么错很困惑。我已经为这个4人游戏编写了大约4天的代码,我一直在努力修复这个特定的代码。每当我加载游戏时,我都可以在这里完成每个场景,但例如,如果我选择问第一个问题,我可以完成所有对话,但%CODE%没有显示,因为@echo已关闭。此外,在完成第一个问题后,它仍然会问我这一部分: @echo off set SCENARIO21=20 set WEAPON1=gun set DOG1=buddy set SCENARIO11=broke

我什么都试过了,我对编码很陌生,所以代码很简单,但我对到底是什么错很困惑。我已经为这个4人游戏编写了大约4天的代码,我一直在努力修复这个特定的代码。每当我加载游戏时,我都可以在这里完成每个场景,但例如,如果我选择问第一个问题,我可以完成所有对话,但%CODE%没有显示,因为@echo已关闭。此外,在完成第一个问题后,它仍然会问我这一部分:

@echo off
set SCENARIO21=20
set WEAPON1=gun
set DOG1=buddy
set SCENARIO11=broken laptop
set ALIVE1=yes
:day51
cls
echo.
echo     Player 1          %SCENARIO21%          %WEAPON1%          %SCENARIO11%
echo     %DOG1%
echo.
echo.
echo Day 5
echo.
echo That was a close one, im glad i got that jacket off when i did...that could've ended really badly...
pause
cls
echo Dang this road seems to go on forever...
pause
cls
echo Woah...
pause
cls
echo That house looks...normal...
pause
cls
echo Is somebody in there?
pause
cls
echo Come on who would live in that house though...
pause
cls
echo Its old, worn down, the roof is bowed, the paint is peeling...
pause
cls
echo And ew...that furniture looks like something from the 2000s
pause
cls
echo Whoever lived there last must've been an old couple...really old...
pause
cls
echo Maybe there is someone in there
pause
cls
echo The windows look like they're sparkling...
pause
cls
echo Wow. Is that a...?
pause
cls
echo A um...what are those called...Oh yeah...
pause
cls
echo A plant?
pause
cls
echo No...it couldn't be
pause
cls
echo The world's last farmer died about 70 years ago...
pause
cls
echo The 2100s...
pause
cls
echo No one knows how to plant anything, let alone GROW anything anymore...
pause
cls
echo Atleast thats what i thought...
pause
cls
echo I wonder if i should go in...
pause
if %ALIVE1%==yes (
cls
echo Player 1
pause
cls
echo Player 1
echo This house gives me a strange feeling...i can't tell if it's good or bad...
echo -Yes (go in, check the house, maybe it has a planting guide...or maybe theres someone in there...and hey if there is someone, why wouldn't they help you)
echo -No (screw that, its not worth it, if you go in your gonna die, duh...anyways what could be of use in a house as old as the 2000s)
set /p SCENARIO51=Should you go in the house?
if %SCENARIO51%==yes (
cls
echo You walk into the home...
pause
cls
echo Hello?
pause
cls
echo *distant voice* Hello...why are you in my home?
pause
cls
echo Sorry sir...ma'm...um i wasn't trying to bother you...
pause
cls
echo *distant voice* You didn't answer my question...and it's sir, thank you...
pause
cls
echo Oh...i came in because i saw the plants outside...
pause
cls
echo *distant voice* And? Is that your only reason...
pause
cls
echo Well i haven't seen plants until now...i was wondering how?
pause
cls
echo *distant voice* YOU'VE NEVER SEEN PLANTS? THIS IS WHY I GO AGAINST THE SYSTEM...
pause
cls
echo What system sir?
pause
cls
echo *distant voice* If we're going to have a conversation come sit with me...walk to the end of the hall and take a left into my room...
pause
cls
echo You walked into the room of the strange voice and found an old man sitting in a chair that looked like a bubble of water being squished...
pause
cls
echo *Old Man* Im Alexander...im 170 years old...
pause
cls
echo H-h-how?
pause
cls
echo *Alexander* Okay i don't have all day i must attend to other things...I'll tell you what
echo I'll answer 1 question...any question...
pause
cls
if %SCENARIO51%==yes
echo This is your chance...
echo -1 (How did this all start?)
echo -2 (How do i get to the city of Lillian?)
echo -3 (How do i live forever just like you?)
set /p SCENARIOP51=What would you like to ask?
if %SCENARIOP51%==1 (
cls
echo *Alexander* Wow...good question...
echo It started in 2100...
pause
cls
echo When the last farmer died?
pause
cls
echo *Alexander* No, when the last farmer turned immortal...me
pause
cls
echo No i saw it on the news drone...he's dead...
pause
cls
set CODE=LSON5676
echo *Alexander* AGAIN...Sorry, that was the system's news drone...they tend to "confuse" everyone's story to make themselfs look better...
echo Anyways...in 2100 two groups of hacking experts went to war...
pause
cls
echo It ended when one of the groups found a way to literally melt the other groups computers into green radioactive goop...
echo No one really knows for sure how the war was started but most say it was because one group had a hostage...
pause
cls
echo The hostage was said to be the head hacker for the opposing group that was finding some cure...his name was Larson...
echo But for some reason when asking for Larson back the opposing group requested they send %CODE% back...
pause
cls
echo That sounds like a code...
echo better write it down...
echo         %CODE%
pause
cls
echo *Alexander* It was all for some stupid reason in my opionion anyways...
echo But back to what happened...
echo After they figured out how to turn the computer into this green goop..they did it to all their computers...
echo Little did they know the goop became radioactive Artificial Intelligence...it could think on its own...
echo And it spread like wild fire...any technology it touched became more green goop...
echo Something else they didn't realize is the goop could sink into your skin with no problem at all...
echo It goes into your veins and overclocks your heart...
echo It was a nano-technology weapon...atomic level capabilities...
echo It was a devastation...
echo And thats all i know...
pause
cls
echo Thank you Alexander...this information won't go to waste...
pause
set ALIVE1=yes
)
if %SCENARIOP51%==2 (
cls
set CODE=5676
echo *Alexander* HA! thats simple...
echo you're not that far either...
echo Go down the road and take the 3rd right
echo You'll be right in front of it...
pause
cls
echo You followed his advice and fell into a trap
pause
cls
type "the end.txt"
pause
cls
set ALIVE1=no
)
if %SCENARIOP51%==3 (
cls
echo *Alexander* Come with me ill show you...
echo This guy seems kinda fishy...
echo Go (go with Alexander to find out what makes him live forever)
echo Leave (Don't follow Alexander, say you have a group waiting outside and you need to get back to them...)
)
if %SCENARIOP51%==3 (
set /p SCENARIOPP51=Do you want to follow Alexander?
)
if %SCENARIOP51%==3 (
if %SCENARIOPP51%==go (
cls
set CODE=LSON5676
echo *Alexander* you aren't smartest are you?
pause
cls
echo You turn around and...
pause
cls
echo *BANG*
pause
cls
echo You died...
pause
cls
type "the end.txt"
pause
set ALIVE1=no
)
if %SCENARIOPP51%==leave (
cls
set CODE=LSON5676
echo *Alexander* I know you're not with anyone but that dog of yours %DOG1%...
pause
cls
echo How do you know his name?
pause
cls
echo *Alexander* you called him to come as you walked down the street cause he was sniffing something...i over heard...
echo I respect your efforts to not fall into traps though...
echo Take this...
pause
cls
echo Alexander handed you a small square of yellow paper with the writing %CODE% on it...
pause
cls
echo *Alexander* take the sticky note and get out...
pause
cls
echo You take the sticky note and leave the house...
pause
cls
echo Whats a sticky note?
pause
)
)
if %SCENARIO51%==no (
cls
echo That thing gives me the creeps...
echo Bye bye house of horror...
set SCENARIO51=none
pause
set ALIVE1=yes
)
)
)
set END=0
if %ALIVE1%==no (
set /a END=%END%+1
)
if %END%==1 (
exit
)
goto day61


:day61
echo yay!
pause
exit
即使%SCENARIOP51%==1,它仍然设置了me/p SCENARIOP51,即使%SCENARIOP51%不等于3。请帮忙,非常感谢。谢谢!:)

注意到这是偶然的吗<代码>)如果,则结束
。如果您想在此处实际显示
,则需要通过编码
^)
来转义
。但缺点是,您的
if
在很多行中没有关闭(我不打算查看所有代码),并且您的
if%SCENARIO51%
打开(另一个)嵌套代码块

当遇到控制代码块(if、for)的指令时,在代码块(括号内的行序列)内,任何
%var%
都将替换为该变量的值。因此,改变
SCENARIO51
set/p
将在块内使用
SCENARIO51
previous

你需要看看
delayedexpansion
——数百篇关于这方面的文章

同时也要注意:单独回复Enter到
set/p
将保持变量不变

由于您使用的是
set/p
,因此还应使用该格式

if %ALIVE1%==yes (
cls
echo Player 1
pause
cls
echo Player 1
echo This house gives me a strange feeling...i can't tell if it's good or bad...
echo -Yes (go in, check the house, maybe it has a planting guide...or maybe theres someone in there...and hey if there is someone, why wouldn't they help you)
以便对包含字符串的空/分隔符具有某种免疫力

此外,应用于
if
/i
开关将使比较不区分大小写

学习批处理子程序可能会对您有所帮助。请参见提示文档中的
call/?

注意到这是偶然的吗<代码>)
如果,则结束
。如果您想在此处实际显示
,则需要通过编码
^)
来转义
。但缺点是,您的
if
在很多行中没有关闭(我不打算查看所有代码),并且您的
if%SCENARIO51%
打开(另一个)嵌套代码块

当遇到控制代码块(if、for)的指令时,在代码块(括号内的行序列)内,任何
%var%
都将替换为该变量的值。因此,改变
SCENARIO51
set/p
将在块内使用
SCENARIO51
previous

你需要看看
delayedexpansion
——数百篇关于这方面的文章

同时也要注意:单独回复Enter到
set/p
将保持变量不变

由于您使用的是
set/p
,因此还应使用该格式

if %ALIVE1%==yes (
cls
echo Player 1
pause
cls
echo Player 1
echo This house gives me a strange feeling...i can't tell if it's good or bad...
echo -Yes (go in, check the house, maybe it has a planting guide...or maybe theres someone in there...and hey if there is someone, why wouldn't they help you)
以便对包含字符串的空/分隔符具有某种免疫力

此外,应用于
if
/i
开关将使比较不区分大小写


学习批处理子程序可能会对您有所帮助。请参见提示文档中的
call/?

非常感谢您,我一定会查看通话/?读到delayedexpansion你帮了大忙D@magoo如果此答案解决了您的问题,请确保通过单击复选标记将其颜色更改为绿色,将其标记为您的答案。它甚至会奖励你;)非常感谢,我一定会查电话的?读到delayedexpansion你帮了大忙D@magoo如果此答案解决了您的问题,请确保通过单击复选标记将其颜色更改为绿色,将其标记为您的答案。它甚至会奖励你;)
if "%varname%"=="targetstring" ...