所以我在使用set / a更改文本时遇到问题 这是我的剧本
:wep
cls
if %gold% lss 50 (
echo not enough gold
pause >nul
goto shop
)
if %weap%==Stick (
echo too low on level
pause >nul
goto shop
)
if %wepugrd% lss 1 (
echo You don't have any upgrades
pause
goto shop
)
cls
echo Your Weapon is Being Upgraded
echo.
echo WAIT A FEW SECONDS
ping localhost -n 3 >nul
set /a weapdmg=%weapdmg% + 5
set /a weap=Stick
set /a wepugrd=%wepugrd% - 1
set /a gold=%gold% - 50
echo weapon upgraded
pause
goto shop
最后一部分设置/ a weapon = Stick 这是早先的拳头 但它只是将拳头改为0而不是改为坚持 我能得到一些帮助吗? 感谢名单
答案 0 :(得分:0)
使用此代码:
:wep
cls
if %gold% lss 50 (
echo not enough gold
pause >nul
goto shop
)
if "%weap%"=="Stick" (
echo too low on level
pause >nul
goto shop
)
if %wepugrd% lss 1 (
echo You don't have any upgrades
pause
goto shop
)
cls
echo Your Weapon is Being Upgraded
echo.
echo WAIT A FEW SECONDS
%SystemRoot%\System32\ping.exe localhost -n 3 >nul
set /a weapdmg+=5
set "weap=Stick"
set /a wepugrd-=1
set /a gold-=50
echo weapon upgraded
pause
goto shop
正如npocmaka所写,切换/A
仅用于算术运算,如果只应将一个字符串赋值给变量,则无法使用。
如上所示,也可以使用简短形式对现有值添加或减去整数。
请阅读this answer,了解将weap=Stick
括在双引号中的原因。