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. !var!thisの代わりに this のように、影響を受ける変数にアクセスする必要もあります%var%

setlocal enabledelayedexpansionバッチファイルで変数の展開が遅れます。プログラムのコンテキストでこれが意味することは、for ループ内から変数を更新できるということです。

于 2015-03-03T23:26:12.037 に答える