How to continue on keypress OR do something else by entering 1 in batch -


i'm trying make simple text-based game , trying design fighting mechanics. right now, once enter fight have either type "1" attack or "2" enter fightmenu. want change can press space regular attack, still able type "1" open fightmenu. here code far if you're interested:

:fighting cls set /a yourhit=%random% %%dmg% set /a theirhit=%random% %%theirdmg% set /a armor = %armor% - %theirhit% if %theirhit% gtr %armor% set /a armor = 0 & set /a hp = %hp% - %theirhit% if %yourhit% geq %theirhp% goto winner if %theirhit% gtr %hp% goto loser set /a theirhp = %theirhp% - %yourhit% echo. call :fightheadsup echo  - hit them %yourhit%! echo. echo  - hit %theirhit%! echo. echo  1.continue attacking echo  2.return fight menu echo. set /p input12=enter: if %input12% equ 1 goto fighting if %input12% equ 2 goto fightmenu goto fightmenu 

enclose compared values in pair of "double quotes" follows (get used always value empty or contain blank space character, in particular value entered user):

if "%input12%" equ " " goto fighting if "%input12%" equ "1" goto fightmenu 

another approach: set default value in advance (self-explained in code):

echo. echo  1. continue attacking ^(default choice, hitting ^<enter^> suffices^) echo  2. return fight menu echo. set "input12=1" set /p "input12=your entry [default=%input12%]:" if "%input12%" equ "1" goto fighting rem superabundant: if "%input12%" equ "2" goto fightmenu goto fightmenu 

note proper escaping <, >, ( , ) characters in echo 1. ... command


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -