Henry Kertauferpaufer
asked on
How do you subtract a number from a variable in a batch file?
I can't figure out how to make a lives system for my game and I need to know how.
Here is my code for the lives;
I expected it to output 'You have 5 lives.' in the first section, and 'You now have 4 lives.' in the second part, but instead, I got 'You have !lives! lives and 'You now have !live! lives.'
Here is my code for the lives;
SET lives=5
:Scene1
CLS
ECHO o Woof!
ECHO /0\ ,###@'
ECHO / \ / \
ECHO #########################################
ECHO.
ECHO You are walking along the dirt
ECHO road with your backpack and trusty dog Steve.
ECHO You have !lives! lives.
PAUSE
CLS
. . .
:WinFight1
SET /a lives-=1
CLS
ECHO o
ECHO /0\ ,###@ w \__,. \__,.
ECHO / \ / \ 3--`~ /--,^ /--,^
ECHO #########################################
ECHO.
ECHO You won the fight!
ECHO You now have !lives! lives.
PAUSE
GOTO Scene2
I expected it to output 'You have 5 lives.' in the first section, and 'You now have 4 lives.' in the second part, but instead, I got 'You have !lives! lives and 'You now have !live! lives.'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What a shame the OP has not responded, I really got carried away getting into how he could enhance this a lot further
Open in new window