lundi 28 janvier 2019

How to remove negative symbols from negative numbers in batch

I'm setting up a line of text that will tell if you have lost or gained something, but whenever the value is negative the (-) symbol is always there. I've attempted to search up how to fix this but have not found anything.

:grocerycomplete
set /a randomsurvivors=%random% %%3 - 1
if %randomsurvivors% LSS 0 (
    set porn=lost
) else (
    set porn=gained
)
echo ========================
echo You have looted the Grocery Store!
echo You have %porn% %randomsurvivors% Survivor(s)!

"randomsurvivors" generates a number between 1 and -1. The number is then read and if it is <0 it will say lost and if it >0 it will say gained. Whenever it is -1 it will say:

========================
You have looted the Grocery Store!
You have lost -1 Survivor(s)!

I want for it to say:

========================
You have looted the Grocery Store!
You have lost 1 Survivor(s)!




Aucun commentaire:

Enregistrer un commentaire