Open a command prompt window, enter set /?
and read all output help pages carefully.
It is explained that when using set for an arithmetic expression, i.e. set /A
, then variable names can be specified directly without expansion. Windows command processor interprets automatically each string not being a number or an operator as name of a variable and access the current variable value on evaluating the arithmetic expression.
Next run in command prompt window if /?
and read again all output help pages carefully.
The line
if "!monsterhealth!" == lss 0 goto tewin
is definitely invalid as it contains the operator ==
and the operator lss
which of course can't work.
This improved code is with all coding mistakes fixed.
:teattack1
set /a health-=monsterdmg
pause
set /a monsterhealth-=playerdmg
pause
if %monsterhealth% LEQ 0 goto tewin
pause
goto testencounter
pause
goto encountermenu
However, the environment variables health
, monsterdmg
, monsterhealth
and playerdmg
should all exist and have an integer value assigned as otherwise Windows command interpreter uses value 0
for each variable making the code not really useful.