mercredi 20 mai 2015

Math in batch if statement

I want to add/subtract a to a variable in an if statement without making a new variable (to the hp and money)

    :Shop
    cls
    echo %sname%        HP -%hp%-        Money -%money%-
    echo.
    echo.
    echo.
    echo.
    echo.
    echo HP Potion -100 coins
    echo    -Increases HP by 10
    echo.
    echo.
    echo Buy? 
    echo  1) Yes
    echo  2)Exit
    set /p ShopCh=">>"
    if not defined ShopCh (goto Shop)
    if %ShopCh%==1 set /a %hp% + 10 & set /a %money% - 100 & goto GameScreen
    if %ShopCh%==2 (goto GameScreen)
    echo Please Choose
    cls
    goto Shop
    pause
    cls

Aucun commentaire:

Enregistrer un commentaire