Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Script not working!  (Read 5335 times)

0 Members and 1 Guest are viewing this topic.

Nahbanhaban

    Topic Starter


    Newbie

    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 7
    Script not working!
    « on: November 19, 2013, 10:28:05 PM »
    It ends whenever the command 'goto' is involved

    @echo off

    title %name% - The Fishing Game V 0.2(alpha)

    color 0f
    pause
    echo --------------
    echo AlexSoft Copyright-2013
    echo --------------
    pause
    color 0c
    echo ERROR LOADING TFG.mp3
    pause
    color 0f
    echo __________________
    echo.   
    echo ~THE FISHING GAME~
    echo.   
    echo __________________
    echo.                  
    echo (Future ASCII ART HERE)
    echo Type Start to start game, type exit to quit.
    echo Type Plan to view planned ideas.
    echo Contact me: (TBA)
    echo Remember, as of V 0.2, you cannot save the game!
    if %input%==Start goto Gamestart

    :Gamestart
    echo You are waking up
    pause
    echo You are up
    pause
    echo You yell hello
    pause
    echo No response.
    pause
    echo You don't remeber what happened, how you got here, or even your name.
    pause
    echo Then you think about how you need to survive.
    echo.
    echo You arn't trained to survive in the wild.
    pause
    echo But then you remember, you're not trainined to do anything, heck, you arn't even 'trained' to know your name.
    pause
    echo You say to yourself, "Now what?"
    pause
    echo To start making a shelter, press A
    echo To look around for any others, press B
    if %input%==A goto A1
    if %input%==B goto B1

    :A1

    echo You look around for a good place to make shelter.
    pause
    echo You find a good spot under a large rock for sleeping, but its too narrow to make a shelter in.
    pause
    echo To make a shelter here, Press A
    echo To keep looking, Press B
    if %input%==A goto A2
    if %input%==B goto B2

    :B1

    echo While looking, you were attacked by 2 wild wolves.
    pause
    echo You have died...
    pause
    goto options


    :A2

    echo Once you're in, you feel something large on your leg.
    echo.
    echo It turns out that hole was a home to a nest of scorpions, which, so far luck for you, havn't attacked.
    pause
    echo You slowly move out safely.
    pause
    echo but your not safe
    echo They have swarmed out of the ledge and you run
    echo Though you dont know that it is the animal instinct is to kill something running from you, because only prey would run from you.
    pause
    echo As you may have seen where this is going, you felt a sharp pain in your leg.
    pause
    echo To great relief, it was only a thorn.
    echo But, while you take that thorn out, a scorpion is under you.
    pause
    echo This time it stings you...
    pause
    echo You have died...
    pause
    goto options

    :B2

    echo Sorry, this is as far as we have scripted!
    echo.
    echo retry for a different story/ending!
    pause
    echo Goodbye
    exit
    -Mr33

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Script not working!
    « Reply #1 on: November 19, 2013, 11:39:49 PM »
    Test it a little bit at a time.
    Your IF statement with not work if there is no input.
    What does %input% mean? Where was it set?

    Nahbanhaban

      Topic Starter


      Newbie

      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 7
      Re: Script not working!
      « Reply #2 on: November 20, 2013, 11:14:06 AM »
      It closes down at any goto command.

      revised script(still doesn't work)

      @echo off

      title %name% - The Fishing Game V 0.2(alpha)

      color 0f
      pause
      echo --------------
      echo AlexSoft Copyright-2013
      echo --------------
      pause
      color 0c
      echo ERROR LOADING TFG.mp3
      pause
      color 0f
      echo __________________
      echo.   
      echo ~THE FISHING GAME~
      echo.   
      echo __________________
      echo.                  
      echo (Future ASCII ART HERE)
      :options
      echo Type New to start game, type exit to quit.
      echo Type Plan to view planned ideas.
      echo Contact me: (TBA)
      echo Remember, as of V 0.2, you cannot save the game!
      set /p you=">"
      if %you%==New goto Gamestart

      :Gamestart

      cls
      echo You are waking up
      pause
      echo You are up
      pause
      echo You yell hello
      pause
      echo No response.
      pause
      echo You don't remeber what happened, how you got here, or even your name.
      pause
      echo Then you think about how you need to survive.
      echo.
      echo You arn't trained to survive in the wild.
      pause
      echo But then you remember, you're not trainined to do anything, heck, you arn't even 'trained' to know your name.
      pause
      echo You say to yourself, "Now what?"
      pause
      echo To start making a shelter, press A
      echo To look around for any others, press B
      set /p you=">"
      if %you%==A goto A1
      if %you%==B goto B1

      :A1

      cls
      echo You look around for a good place to make shelter.
      pause
      echo You find a good spot under a large rock for sleeping, but its too narrow to make a shelter in.
      pause
      echo To make a shelter here, Press A
      echo To keep looking, Press B
      set /p you=">"
      if %you%==A goto A2
      if %you%==B goto B2

      :B1

      cls
      echo While looking, you were attacked by 2 wild wolves.
      pause
      echo You have died...
      pause
      ping localhost -n 2 >nul
      goto options


      :A2

      cls
      echo Once you're in, you feel something large on your leg.
      echo.
      echo It turns out that hole was a home to a nest of scorpions, which, so far luck for you, havn't attacked.
      pause
      echo You slowly move out safely.
      pause
      echo but your not safe
      echo They have swarmed out of the ledge and you run
      echo Though you dont know that it is the animal instinct is to kill something running from you, because only prey would run from you.
      pause
      echo As you may have seen where this is going, you felt a sharp pain in your leg.
      pause
      echo To great relief, it was only a thorn.
      echo But, while you take that thorn out, a scorpion is under you.
      pause
      echo This time it stings you...
      pause
      echo You have died...
      pause
      ping localhost -n 2 >nul
      goto options

      :B2

      cls
      echo Sorry, this is as far as we have scripted!
      echo.
      echo retry for a different story/ending!
      pause
      ping localhost -n 2 >nul
      goto options


      -Mr33

      Google



        Mentor

        Thanked: 2
        • Certifications: List
        • Experience: Experienced
        • OS: Windows 7
        Re: Script not working!
        « Reply #3 on: November 20, 2013, 11:30:32 AM »
        It works for me... can you provide more information? Where exactly does it crash? Does it not even start up correctly?

        Also you are missing an "options" label, - This might be the cause of your issue.
        « Last Edit: November 20, 2013, 12:14:55 PM by Google »

        Allan

        • Moderator

        • Mastermind
        • Thanked: 1260
        • Experience: Guru
        • OS: Windows 10
        Re: Script not working!
        « Reply #4 on: November 20, 2013, 11:54:44 AM »
        I deleted your duplicate post. Please do not post the same question more than once. Thank you.

        Google



          Mentor

          Thanked: 2
          • Certifications: List
          • Experience: Experienced
          • OS: Windows 7
          Re: Script not working!
          « Reply #5 on: November 20, 2013, 12:34:01 PM »
          This should fix most of your problems:

          @echo off

          title %name% - The Fishing Game V 0.2(alpha)

          color 0f
          pause
          echo --------------
          echo AlexSoft Copyright-2013
          echo --------------
          pause
          color 0c
          echo ERROR LOADING TFG.mp3
          pause
          color 0f
          echo __________________
          echo.   
          echo ~THE FISHING GAME~
          echo.   
          echo __________________
          echo.                 
          echo (Future ASCII ART HERE)
          :options
          echo Type New to start game, type exit to quit.
          echo Type Plan to view planned ideas.
          echo Contact me: (TBA)
          echo Remember, as of V 0.2, you cannot save the game!
          set /p you=">" goto checkmenu

          :checkmenu
          if %you%==new goto Gamestart
          if %you%==exit goto closecmd
          :end


          :Gamestart

          @echo off

          cls
          echo You are waking up
          pause
          echo You are up
          pause
          echo You yell hello
          pause
          echo No response.
          pause
          echo You don't remeber what happened, how you got here, or even your name.
          pause
          echo Then you think about how you need to survive.
          pause
          echo You arn't trained to survive in the wild.
          pause
          echo But then you remember, you're not trainined to do anything, heck, you arn't even 'trained' to know your name.
          pause
          echo You say to yourself, "Now what?"
          pause
          echo To start making a shelter, press A
          echo To look around for any others, press B
          set /p you=">" goto checkshelter

          :checkshelter
          if %you%==A goto A1
          if %you%==B goto B1
          if %you%==a goto A1
          if %you%==b goto B1
          :end


          :A1

          cls
          echo You look around for a good place to make shelter.
          pause
          echo You find a good spot under a large rock for sleeping, but its too narrow to make a shelter in.
          pause
          echo To make a shelter here, Press A
          echo To keep looking, Press B
          set /p you=">" goto checkmake

          :checkmake
          if %you%==A goto A2
          if %you%==B goto B2
          if %you%==a goto A2
          if %you%==b goto B2
          :end


          :B1

          cls
          echo While looking, you were attacked by 2 wild wolves.
          pause
          echo You have died...
          pause
          ping localhost -n 2 >nul --> what is the point of this line?
          goto options


          :A2

          cls
          echo Once you're in, you feel something large on your leg.
          echo.
          echo It turns out that hole was a home to a nest of scorpions, which, so far luck for you, havn't attacked.
          pause
          echo You slowly move out safely.
          pause
          echo but your not safe
          echo They have swarmed out of the ledge and you run
          echo Though you dont know that it is the animal instinct is to kill something running from you, because only prey would run from you.
          pause
          echo As you may have seen where this is going, you felt a sharp pain in your leg.
          pause
          echo To great relief, it was only a thorn.
          echo But, while you take that thorn out, a scorpion is under you.
          pause
          echo This time it stings you...
          pause
          echo You have died...
          pause
          ping localhost -n 2 >nul --> What is the point of this line?
          goto options

          :B2

          cls
          echo Sorry, this is as far as we have scripted!
          echo.
          echo retry for a different story/ending!
          pause
          ping localhost -n 2 >nul
          goto options

          :options
          cls
          echo here is where your options would be if it was scripted
          pause
          exit


          :closecmd
          exit


          I have made bold what I changed, and italicized a line for your answer. I would also add more "cls" so that the user doesn't have to look at tons of text at once. Easier on the eyes.

          Let me know if you have any questions.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Script not working!
          « Reply #6 on: November 20, 2013, 12:41:11 PM »
          It helps if you can break your code in little sections. That is how you try are possibilities for an IF statement without going into the whole page of code.
          Look t this:
          Code: [Select]
          set /p you=">"
          if %you%==A goto A1
          if %you%==B goto B1
          exit
          :A1
          echo A1
          This code may or may not work. It will work for A, but not for B
          Do you see  why?

          Google



            Mentor

            Thanked: 2
            • Certifications: List
            • Experience: Experienced
            • OS: Windows 7
            Re: Script not working!
            « Reply #7 on: November 20, 2013, 12:53:57 PM »
            It helps if you can break your code in little sections. That is how you try are possibilities for an IF statement without going into the whole page of code.
            Look t this:
            Code: [Select]
            set /p you=">"
            if %you%==A goto A1
            if %you%==B goto B1
            exit
            :A1
            echo A1
            This code may or may not work. It will work for A, but not for B
            Do you see  why?

            I know this wasn't directed at me - but why doesn't that work? Shouldn't it check if %you% is A. If it is, then goto A1. But if not, shouldn't it move to the next line and check if %you% is b. Then goto B1 if it is, but if not just move on and exit?

            I just saw that it wasn't working so I made a case to check with both instead and it worked.