I’m trying to built a simple dungeon crawler game with batch script, but I keep coming across the error as I’m creating the menu screen. Could anyone please help to point out what I’m going wrong? FIXED cheers guys 🙂
@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
)
I haven’t looked for other problems, but the following statement is creating a variable named “number ” (with a space at the end):
The correct syntax would be