0

我正在制作基于文本的 rpg,但脚本无法正常工作。这与耐力有关。我还有一个任务,取决于你是否拥有一定数量的金币,而该脚本无法正常工作。我将包括图片。

:harvest
cls
echo Press 1) to harvest
set /p input17=enter:
if %input17%==1 set   /a wheat= %wheat% + 5
if %input17%==1 set   /a carrots= %carrots% +4
if %input17%==1 set /a stamina= %stamina% - 25 (this line)
if %stamina% < 0 goto nostamina  (this line)
echo.
echo You get some wheat and some carrots.
echo.
echo check your inventory for accurate numbers.
echo. 
echo Press 1) to go back.
pause >nul
goto insidehouse






    :insidehouse
cls

echo You are now inside of your house.
echo.
echo Press 1) to harvest.
echo Press 2) to sell all crops.
echo Press 3) to go into your inventory.
echo Press 4) to sleep eight hours.
echo Press 5) to check for quests.
set /p input16=enter:
if %input16% EQU 1 goto harvest 
if %input16% EQU 2 goto market
if %input16% EQU 3 goto Inventory1
if %input16% EQU 4 goto sleep
if %input16% EQU 5 (and) if %gold% LSS 0 goto shopping (this line)
4

1 回答 1

0

您没有提供太多代码可以使用,所以我只能猜测一个解决方案。

我最好的猜测是您正在尝试从 for 循环内部更新变量。如果是这种情况,您需要将此行添加到批处理文件的顶部:setlocal enabledelayedexpansion. 您还需要像 this!var!而不是 this那样访问受影响的变量%var%

setlocal enabledelayedexpansion导致您的批处理文件中的变量扩展延迟。这在您的程序上下文中意味着可以从 for 循环中更新变量。

于 2015-03-03T23:26:12.037 回答