...

View Full Version : Need help with batch file



ChaosIntoOrder
11-16-2012, 08:50 PM
So I've been working on Pokemon as a batch file.
Everything has been working fine until i made the pokeshop.

The player has a certain amount of money: %money%
Each item has a cost: %greatballcost%

But for whatever reason, certain amounts of money are incorrectly compared as less than the cost, for instance 2700, 1337, 27000, and others.

Here is the code for this area. Any help would be appreciated if you could help me fix this problem.


:m-pewterpokeshop
cls
set pokeballcost=125
set greatballcost=300
set potioncost=250
set superpotioncost=500
echo Money - $ %money%
echo Shopkeeper: "Welcome! What can I get you?"
echo 0 - Exit
echo 1 - Pokeball [$ %pokeballcost%][1]
echo 2 - Greatball [$ %greatballcost%][1]
echo 3 - Potion [$ %potioncost%][1]
echo 4 - Super Potion[$ %superpotioncost%][1]
set /p choice=
if '%choice%'=='0' goto m-PewterCity
if '%choice%'=='1' goto m-pewterpokeshop-pokeball
if '%choice%'=='2' goto m-pewterpokeshop-greatball
if '%choice%'=='3' goto m-pewterpokeshop-potion
if '%choice%'=='4' goto m-pewterpokeshop-superpotion
goto m-pewterpokeshop

:m-pewterpokeshop-superpotion
if /i '%money%' LSS '%superpotioncost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-500
set /a superpotionamount=%superpotionamount%+1
echo Received Super Potion [%superpotionamount%]
echo Thanks!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-badfunds
echo You don't have enough money!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-pokeball
if /i '%money%' LSS '%pokeballcost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-100
set /a pokeballamount=%pokeballamount%+1
echo Received Pokeball [%pokeballamount%]
echo Thanks!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-greatball
if /i '%money%' LSS '%greatballcost%' echo True
if /i not '%money%' LSS '%greatballcost%' echo False
if /i '%money%' GTR '%greatballcost%' echo True
if /i not '%money%' GTR '%greatballcost%' echo False
if /i '%money%' LSS '%greatballcost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-300
set /a greatballamount=%greatballamount%+1
echo Received Greatball [%greatballamount%]
echo Thanks!
pause
goto m-pewterpokeshop

:m-pewterpokeshop-potion
if /i '%money%' LSS '%potioncost%' goto m-pewterpokeshop-badfunds
set /a money=%money%-250
set potion=potion
set /a potionamount=%potionamount%+1
echo Received Potion [%potionamount%]
echo Thanks!
pause
goto m-pewterpokeshop



Also, this is only an excerpt and you would need several more large chunks to test it. if you would like, i can post those as well.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum