我目前正在制作一个游戏,其中有一个说服系统。我为所有系统设置了所有的代码,但是之后我又设置了2个代码,并开始给我一个错误,说'此时(数字)没有预期'。当我第二次选择了2,第三次选择了3。got goto在当时是意外的
代码是这样的。
@echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
set name=Quantum
cls
color 0a
Echo King Redwood: So 2000?
pause >nul
echo.
call :colorText 09 "1. 2500"
echo.
call :colorText 0e "2. 3000"
echo.
call :colorText 0c "3. 4000"
echo.
echo 4. 2000
echo.
set /p "purs=Enter:"
if /i %purs% == 1 (
goto CheckB)
if /i %purs% == 2 (
goto CheckY)
if /i %purs% == 3 (
goto CheckR)
if /i %purs% == 4 (
goto Convo)
:CheckB
set bleu=%random:~-2,1%
if %bleu% GTR 10 (
goto CheckB)
if %bleu% LSS 0 (
goto CheckB)
set /a num = 3
set /a reward = 2500
goto Res
:CheckY
set Yel=%random:~-2,1%
if %Yel% GTR 10 (
goto CheckY)
if %Yel% LSS 0 (
goto CheckY)
set /a num = 5
set reward = 3000
goto Res
:CheckR
set red=%random:~-2,1%
if %red% GTR 10 (
goto CheckB)
if %red% LSS 0 (
goto CheckB)
set /a num = 7
set /a reward = 4000
goto Res
:Convo
set /a reward = 2000
Echo %name%: I think that is a reasonable price.
Echo King Redwood: Very well.
Echo King Redwood: We will now take you to make sure you are
echo ready.
pause >nul
:Res
if %bleu% GEQ %num% goto Succeed
if NOT %bleu% GEQ %num% goto Fail
:Succeed
Echo %name%: I think that the struggles for such a long trip will be more then that
Echo %name%: How about %reward%?
Echo King Redwod: OK %reward% will work.
pause >nul
goto end
:Fail
Echo %name%: I think that you can give me %reward%.
Echo %name%: You know, for the struggles that there will be along the way.
echo If 2000 isn't good enough for you, I'll just have someone else do it.
pause >nul
:end
exit
:colorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
我做了一个编辑,我改变了set num并设置了奖励:CheckR和Y现在改为设置/ a。但这仍然给我一个错误。 – QuantumPrimus
注释掉@echo off,看看实际发生了什么;不要双击批处理文件,而是通过打开命令提示符窗口并键入它的路径来运行它... – aschipfl
例如,'%bleu%'是':res'下的空字符串,因为'bleu'不是通过':CheckY'或':CheckR'或':Convo'设置(此列表可能不完整)。因此,'如果%bleu%GEQ%num%goto成功'的结果类似于'如果GEQ 3成功'... ...显然是错误的语法...... – JosefZ