你好我在Windows批处理中制作一个基于文本的基本冒险游戏,我不能在用户输入中有空格。
我的代码是:
:quest1
cls
echo MUM: %PlayerName%, your breakfast is ready!!!
set /p PlayerInput1=">"
if %PlayerInput1%=="look around" echo you are in your bedroom upstairs in your house, in %PlayerHome%
使用PlayerInput1我希望用户输入环顾四周但是当我尝试运行它时它说: 周围==“环顾四周”此时出乎意料
我该如何解决这个问题
答案 0 :(得分:1)
将字符串放在你的变量之间:
set /p "PlayerInput1=^> "
if "%PlayerInput1%"=="look around" echo you are in your bedroom upstairs in your house, in %PlayerHome%
答案 1 :(得分:1)
:quest1
cls
echo MUM: %PlayerName%, your breakfast is ready!!!
set /p PlayerInput1=">"
if "%PlayerInput1%" =="look around" (echo "you are in your bedroom upstairs in your house, in" "%PlayerHome%")
你忘了if"%PlayerInput1%"中的引号,并且echo不需要介于()之间,但这是一个很好的做法。 *感谢@Dennisvagils *