cmd - Why does the command GOTO atack1 not result in executing the code below line :attack1 on batch file execution? -
i've started learn batch/shell while ago. , started make text based rpg called bpg. anyways, poured day making basic structure of , found out cmd closes when use attack trigger. ran on million times, can't find wrong it. please help.
the batch file can downloaded https://www.dropbox.com/s/f8r7cs0tvo8qhs8/bpg.bat?dl=0
here code:
@echo off if not "%1" == "max" start /max cmd /c %0 max & exit/b title bpg 1 batch of monsters setlocal enabledelayedexpansion color 2 :menu cls echo ______ _______ _______ echo ___ \ ____ i ____ \ echo i ii ii i \/ echo __ _____i i ____ echo i \ \ i i \_ echo i___i ii i___i echo i______/ i_/ i_______i batch of monsters echo. echo. echo 1) begin echo. echo 2) exit echo. set /p c=bpg: if "%c%" == "1" goto new if "%c%" == "2" exit goto menu :new set health=100 set enemyhealth=30 set playerdmg=10 set monsterdmg=10 goto home :home cls echo -------------------- echo welcome bpg echo -------------------- echo (noobs can f off) echo. echo 1) battle echo 2) menu echo. set /p c=bpg if "!c!" == "1" goto encounter1 if "!c!" == "2" goto menu goto home :encounter1 cls echo -------------------- echo you: %health% echo enemy: %enemyhealth% echo -------------------- echo. echo 1) attack echo. echo 2) flee echo. set /p c=bpg if "!c!" == "1" goto atack1 if "!c!" == "2" goto home goto encounter1 :attack1 set /a !health!-=!monsterdmg! set /a !monsterhealth!-=!playerdmg! if !monsterhealth! lss 0 goto win goto encounter :win cls echo. echo -------------------- echo win! echo -------------------- echo _.oood"""""""booo._ echo _.o"" _____ . ""o._ echo op" _.ooo"""" """"oio._. "yo echo o8 op _.-": i"._. .8o echo d' o8',-" : i/ ,\. .b echo d' d.-" : i: (( .\ echo 8' d' """"": : i ii\_/. .8 echo 8 8' : : i) _ ii i.i 8 echo ,8 8 : : /)i \ ii i\_ii i8 8. echo 8' ,8 : : " /_) i.:' i i8. .8 echo 8 8' : : _ _-' \ ' __ __ 8 echo 8 8 : : \i__ i i 8i 8 echo 8 8. : : ii i-:' 8i 8 echo 8. .8 / __/ i__ i__i \ i__i,8 echo 8 8 .' \ / __ . . . . . .8ll8' echo 8 8.' -. ( ,' .. i ,-i8 8 echo 8.(__________dd_) \__/ ' 0i...: i: (8 ,8 echo y. y. :/i i,\i. .p echo y. "8. .,o i i,i". ,p echo "8. "yo_ ipi". ,8" echo "y_ "ooo.__ __.ooi". . _p" echo '"oo_ """"" . _oo""' echo ."""boooooood"""'. echo. echo. pause
if "!c!" == "1" goto atack1
look million-and-first time @ command.
now - why wouldn't reach label ":attack1"
and if ever reach label,
set /a !health!-=!monsterdmg!
will subtract contents of monsterdmg
variable name (the contents of health
)
this error repeated on other lines.
what's obsession !var!
? need !var!
when dealing values changing within code block - loop. syntax works @ other times, beware - may have unforseen side-effects. better stick %var%
unless need use !var!
form.
Comments
Post a Comment