0

我正在尝试使用批处理脚本构建一个简单的地牢爬虫游戏,但是在创建菜单屏幕时我不断遇到错误。任何人都可以帮忙指出我哪里出错了吗?固定欢呼伙计们:)

@echo off 
cls
echo LOADING GAME
ping localhost -n 2 >nul
@echo off
color 8a
title Josh's Game Beta

:loop 
:menu
cls 
echo You get to...
echo.
echo 1) Start
echo.
echo 2) Info
echo.
echo 3) Exit
set /p number = 

if not defined number (
cls
goto loop
)

if %number% == 1 goto game 
if %number% == 2 goto info 
if %number% == 3 exit

:game
cls
echo Who are you?
set /p name = 
echo Hello, %name% 
echo Do you want to start the game(Y/N)
set /p start =

if %start% == Y goto lvl1
if %start% == y goto lvl1
if %start% == N goto menu
if %start% == n goto menu 
if not defined start (
cls
goto menu 
)
4

1 回答 1

0

我没有寻找其他问题,但以下语句正在创建一个名为“number”的变量(末尾有一个空格):

set /p number = 

正确的语法是

set /p "number="
于 2013-01-27T22:34:11.837 回答