1.

Solve : Scripting Help2?

Answer»

Im trying to create a game in batch. I am beginning to get worried since many of my scripts seem to not be working. Can cmd break?
Quote

@echo off
PAUSE
if exist Level.txt. goto cash
echo 1.0>Level.txt
:cash
if exist Cash.txt. goto eng
echo 500>Cash.txt
:eng
if exist Energy1.txt. goto eng2
echo 10>Energy1.txt
:eng2
if exist Energy2.txt. goto exp
echo 10>Energy2.txt
:exp
if exist exp1.txt. goto exp2
echo 0.0>exp1.txt
:exp2
if exist exp2.txt. goto start
echo 10>exp2.txt
:start
set /p Lev= <Level.txt
set /p Cash= <Cash.txt
set /p eng1= <Energy1.txt
set /p eng2= <Energy2.txt
set /p exp1= <exp1.txt
set /p exp2= <exp2.txt
cls
echo Level %Lev%
echo Experience %exp1% / %exp2%
echo MONEY %Cash%
echo Energy %eng1% / %eng2%
echo Zach Wars
echo ---------
pause
:Jobs
cls
echo Level %Lev%
echo Experience %exp1% / %exp2%
echo Money %Cash%
echo Energy %eng1% / %eng2%
echo Zach Wars
echo ---------
echo Jobs
echo.
echo MUGGING Job. 1 Exp. 200 Dollars. -1 Energy. Press 1 to Perform Job.
set /p Job=
if %Job%==1 goto mug
echo This is an incorrect Selection
pause
goto Jobs
:mug
if %eng1%>0 goto mug1
echo Not enough energy to perform Job
pause
goto Jobs
:mug1
echo %eng1%-1>Energy1.txt
echo %Cash%+200>Cash.txt
echo %exp1%+1>exp1.txt
echo Job Completed
pause
if %exp1%>%exp2% goto lvup
goto Jobs
:lvup
set Lev=%Lev%+1
set exp1=0
set exp2=%exp2%+1
set eng1=%eng2%
set eng2=%eng2%+1
echo Congrats! You have leveled up!
pause
goto Jobs
batch is not really used for creating games or programming in general. When adding or subtracting integers in batch, use SET /A. Example:

set /a varname+=1
set /a var2=%varname%^2/40
You can use brackets, as you normally would. Note:
+=addition
-=subtraction
*=multiplication
/=division
^=exponent
?=roots. I don't KNOW this one. Quote from: Helpmeh on December 23, 2009, 06:47:12 AM

?=roots. I don't know this one.

Don't know where you got that from. According to the SET help, viewed by typing SET /? at the prompt they are

Code: [Select] () - grouping
! ~ - - unary operators
* / % - arithmetic operators
+ - - arithmetic operators
<< >> - logical shift
& - bitwise and
^ - bitwise exclusive or
| - bitwise or
= *= /= %= += -= - assignment
&= ^= |= <<= >>=
, - expression separator
Quote from: Salmon Trout on December 23, 2009, 07:47:59 AM
Don't know where you got that from. According to the SET help, viewed by typing SET /? at the prompt they are

I put the question mark because I didn't know.


Discussion

No Comment Found