当玩家未提供正确输入时,批处理基于文本的游戏错误 [英] Batch text based game bugs when the player doesn't provide the correct input
问题描述
因此,我和另外两个朋友正在尝试使基于文本的游戏批量运行,并且一切都进行得很顺利,除了这一点,通常在基于文本的游戏中,当玩家没有编写正确的输入时,游戏通常会回应类似不知道是什么(玩家输入)"的内容,而在我们的游戏中,它只是出现错误并继续执行下一行,因此,我的问题是,我们如何才能解决此问题并它是基于文本的游戏应该采用的方式吗?
So, me and two other friends are trying to make a text based game running on batch and everything's going smooth, well, except for this one thing, normally on text based games, when a player doesn't write the correct input, the game usually responds something like "don't know what is (the player input)" and in ours, it just bugs and goes on to the next line, so, my question is, how can we be able to fix this and do it the way text based games are supposed to do it?
谢谢!
下面是一些代码:
set/p input="What do you want to do?"
if "%input%"=="play" goto :beg:
if "%input%"=="quit" goto :quit:
if "%input%"=="credits" goto :credits:
if "%input%"=="start" goto :lvl1:
if "%input%"=="ilrdj87imwa" goto :lvl2:
if "%input%"=="valveisevil" goto :lvl3:
pause
推荐答案
在没有看到您正在使用的代码的情况下,很难知道出了什么问题.
Without seeing the code you are using it's hard to know what's going wrong.
尝试使用类似的东西
:LOOP
set /p input=Enter input
if %input%==ok (
goto :CONTINUE
) else (
echo Wrong input
goto :LOOP
)
:CONTINUE
REM Input ok, carry on
更新
Update
set /p input=What do you want to do?
if "%input%"=="play" goto :beg
if "%input%"=="play again" goto :pa
if "%input%"=="quit" goto :quit
:play
echo Play
pause >nul
:pa
echo Play again
pause >nul
:quit
exit >nul
这篇关于当玩家未提供正确输入时,批处理基于文本的游戏错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!