0

我正在批量制作游戏。我知道那批不是很强大,但这是我的第一场比赛。无论如何,我正在做一个 if 声明,如果您通过 1 号门,您将活着,但如果您通过 2 号门,您将死去。不幸的是,当我通过任何一扇门时,程序都会重新启动。在这里,我将向您展示我的代码:

`@echo off
color 02
::stats 
set Badasspts=0

:Beginning
echo Hello what is your name?
set /p name=
echo Hello %name%!
echo You have two doors to go through. Which one? Possible answers: 1 or 2
set /p answer1=
if answer1==1 goto youLive
if answer1==2 goto youDie
:youDie
echo Behind this door is an alligator pit you accidentally fall in and die!
goto Beginning

:youLive
echo Well... well... well... you live this time but now ummm... A wild monster appears. What do you do? Possible answers: hug, attack
set /p hugAttck=
if hugAttack==hug goto hug
if hugAttack==attack goto attack1

:hug
echo You hug that cute furry monster soooo hard that he dies. Plus 1 BADASS points!!!!
pause` 

注意:我正在使用 Notepad++ 编程。它还没有完成,所以是的。

4

2 回答 2

0

目前,两个条件都不为真,程序根本不跳转。它执行“youDie”位,因为程序自然会进入下一行。无论用户输入如何,这两个条件都评估为 false 的原因是 if 语句将字符串“answer1”而不是变量“answer1”与数字进行比较。正确的语法是:if %answer1%==1 goto youLive.

于 2014-01-10T14:03:21.550 回答
0

你没有这样做%answer1%它不起作用。

您正在比较单词 answer1 而不是变量。

就像你写%name%的一样,你需要对答案做同样的事情。

调试时(寻找脚本中的问题),不要关闭回显。

于 2014-01-10T14:06:00.883 回答