2016-09-22 16 views
0

私は、うつ病のティーンエイジャーに関する長いテキストベースのゲームに取り組んでいます。初めに、私はこれを使用:間違ったボタンを押したときにバッチファイルが進行しないようにするにはどうすればよいですか?

@echo off 
echo. 
echo  So, tell me about yourself, what is your name? 
echo. 
echo. 
set /p uname=>>>>>>>" 
echo. 
cls 
echo. 
echo. 
echo  I really do hope this is your last drink, %uname%... 
ping localhost -n 2 >nul 
cls 
goto mainmenu 
:::::::::::::::::::::::::::::::::::::::::::::: 
:mainmenu 
cls 
echo. 
echo   ________________________________________________ 
echo. 
echo   Do you wish to log onto your computer %uname%? 
echo. 
echo. 
echo   Yes or no? If no, you will be sent right back 
echo   here, so you may as well, what better do you 
echo   have to do in your life anyways? 
echo. 
echo   ________________________________________________ 
echo. 
set /p input=">>>>>>>" 
if "%input%"== "yes" goto openscomputer 
if "%input%"== "no" goto mainmenu 
goto mainmenu 
pause >nul 

と私は、それだけでメインメニューを更新しますオプションではありませんでした何かを入力した場合には、うまく働いたが、その後いつでも、私は試してみて、「使います(タブがどんな名前であれ)どんな機能をもさせてもらえません。もし私がそれを取り出しても、私は何をしても進歩します。私のコードのほうがそれほど多くありません。 :

:openscomputer 
cls 
echo. 
echo. 
echo *Opens computer* 
echo.  
echo. 
ping localhost -n 1 >nul 
cls 
echo. 
echo *Opens computer* 
echo  . 
echo. 
ping localhost -n 1 >nul 
cls 
echo. 
echo *Opens computer* 
echo  .. 
echo. 
ping localhost -n 1 >nul 
cls 
echo. 
echo *Opens computer* 
echo  ... 
echo. 
ping localhost -n 1 >nul 
cls 
echo. 
echo *Opens computer* 
echo  .... 
echo. 
ping localhost -n 1 >nul 
cls 
echo. 
echo *Opens computer* 
echo  ..... 
echo. 
ping localhost -n 2 >nul 
cls 
goto openedcomputer 




:openedcomputer 
cls 
echo. 
echo. 
echo   _____________________________ 
echo. 
echo    New Notification! 
echo. 
echo     (1) New IM's 
echo. 
echo   _____________________________ 
echo. 
echo. 
echo    (Press any key to) 
echo. 
echo. 
pause >nul 
goto clicked1 



:clicked1 
cls 
echo   _____________________________ 
echo. 
echo   London has messaged you! 
echo. 
echo   London : Hey! Just got 
echo   back from school, where 
echo   were you today? No one 
echo   saw you. Are you okay? 
echo. 
echo.   Messaged recieved 2:45PM   
echo. 
echo   _____________________________ 
echo. 
echo. 
echo 1) Yeah I'm here, I'm sorry I wasn't feeling well so I stayed home. 
echo 2) Sorry, I missed the bus, haha! 
echo. 
echo (Type which number you wish to say to London.) 
set /p %input1%= ">>>>>>>" 
if "%input1%" == "1" goto sick1 
if "%input1%" == "2" goto bus1 else goto clicked1 


:sick1 
cls 
echo   _____________________________ 
echo. 
echo   London has messaged you! 
echo. 
echo   London : What do you have? 
echo   Are you going to be okay? 
echo.    
echo.   Messaged recieved 2:47PM   
echo. 
echo   _____________________________ 
echo. 
echo. 
echo (Type which number you wish to say to London.) 
echo. 
echo 1) I have a cold. 
echo 2) I don't know. 
set /p %input%= ">>>>>>>" 
if "%input%"=="1" goto cold1 
if "%input%"=="2" goto idk1 
goto sick1 



:bus1 
cls 
echo   _____________________________ 
echo. 
echo   London has messaged you! 
echo. 
echo   London : OMG you had me so 
echo   worried! XD 
echo. 
echo.   Messaged recieved 2:47PM   
echo. 
echo   _____________________________ 
echo. 
echo (Type which number you wish to say to London.) 
set /p %input%= ">>>>>>>" 
if "%input%"=="1" goto dontworry1 
if "%input%"=="2" imhere1 
goto bus1 

は、私はまた、 "%入力%が" == "1"(後藤dontworry1)他(後藤BUS1)AND STILLそれは文句を言わない私は押しても進行させた場合((例えば)入れて試してみました正しいことだけでなく、私がそれを取り出すならば、私は私が何を入力しても進行しませんでした。助けてください。 :/

+3

このヘルプトピックをお読みください:

は、以下のスクリプトを参照してください[、最小完全、かつ検証例を作成する方法](http://stackoverflow.com/help/mcve) – aschipfl

+1

使用[ choice](http://ss64.com/nt/choice.html)を参照してください。 – SomethingDark

+0

デバッグ中にエコーをオンにします。 '%'% '==" 2 "imhere1'にgotoがありません – FloatingKiwi

答えて

1

私はこれが唯一の1 & 2は、したがって、不必要なエラーチェックを取り除く、入力できるようになります、choice /C YN /M ">>>>>>>"を使用して、スクリプトを簡素化しました。

@echo off 
    echo. 
    echo  So, tell me about yourself, what is your name? 
    echo. 
    echo. 
    set /p "uname=>>>>>>>" 
    echo. 
    cls 
    echo. 
    echo. 
    echo  I really do hope this is your last drink, %uname%... 
    timeout /nobreak 1 >nul 
:mainmenu 
    cls 
    echo. 
    echo   ________________________________________________ 
    echo. 
    echo   Do you wish to log onto your computer %uname%? 
    echo. 
    echo. 
    echo   Yes or no? If no, you will be sent right back 
    echo   here, so you may as well, what better do you 
    echo   have to do in your life anyways? 
    echo. 
    echo   ________________________________________________ 
    echo. 
    choice /C YN /M ">>>>>>>" 
    if errorlevel 2 (goto mainmenu) else (goto openscomputer) 
:openscomputer 
    set ".=" 
    :openCompLoop 
     cls 
     echo. 
     echo. 
     echo *Opens computer* 
     echo. %.% 
     echo. 
     if "%.%"=="................" goto openedcomputer 
     ping localhost -n 1 >nul 
     set .=%.%. 
goto :openCompLoop 


:openedcomputer 
    cls 
    echo. 
    echo. 
    echo   _____________________________ 
    echo. 
    echo    New Notification! 
    echo. 
    echo     (1) New IM's 
    echo. 
    echo   _____________________________ 
    echo. 
    echo. 
    echo   (Press any key to check) 
    echo. 
    echo. 
    pause >nul 
goto clicked1 


:clicked1 
    cls 
    echo   _____________________________ 
    echo. 
    echo   London has messaged you! 
    echo. 
    echo   London : Hey! Just got 
    echo   back from school, where 
    echo   were you today? No one 
    echo   saw you. Are you okay? 
    echo. 
    echo.   Messaged recieved 2:45PM   
    echo. 
    echo   _____________________________ 
    echo. 
    echo. 
    echo 1) Yeah I'm here, I'm sorry I wasn't feeling well so I stayed home. 
    echo 2) Sorry, I missed the bus, haha! 
    echo. 
    echo (Type which number you wish to say to London.) 
    echo. 
    choice /C 12 /M ">>>>>>>" 
if errorlevel 2 (goto sick1) else (goto bus1) 


:sick1 
    cls 
    echo   _____________________________ 
    echo. 
    echo   London has messaged you! 
    echo. 
    echo   London : What do you have? 
    echo   Are you going to be okay? 
    echo.    
    echo.   Messaged recieved 2:47PM   
    echo. 
    echo   _____________________________ 
    echo. 
    echo. 
    echo (Type which number you wish to say to London.) 
    echo. 
    echo 1) I have a cold. 
    echo 2) I don't know. 
    echo. 
    choice /C 12 /M ">>>>>>>" 
if errorlevel 2 (goto cold1) else (goto idk1) 

:bus1 
    cls 
    echo   _____________________________ 
    echo. 
    echo   London has messaged you! 
    echo. 
    echo   London : OMG you had me so 
    echo   worried! XD 
    echo. 
    echo.   Messaged recieved 2:47PM   
    echo. 
    echo   _____________________________ 
    echo. 
    echo (Type which number you wish to say to London.) 
    choice /C 12 /M ">>>>>>>" 
if errorlevel 2 (goto dontworry1) else (goto :imhere1) 
関連する問題