vendredi 26 juin 2015

How to use goto after an if statement in batch

I'm sure this question has been asked, or it's obvious, but I can't seem to find the answer! I am making a sort of idle clicker game in batch, and am stuck on going to the upgrades page. The idea is that I want the player to press enter to earn money, and type "upg" to go to the upgrades page. I get an error that says the goto command was not recognized at this time. Then the script closes. Here's what I have:

@echo off
title HackerClicker 1.2.1
color 0a
:start
set /a mon = 0 
echo HkrAssociation Hack protocal v. 1.2.1
echo 2015 HkrAssociation. All rights reserved.
echo.
echo press and hold enter in hack routine to auto-hack and gain money
echo.
set /p= "PRESS ANY KEY TO START ROUTINE"
goto routine

:routine
cls
echo Hack Routine v. 1.2.1
echo. 
echo Balance: $%mon%
echo.
echo Type "upg" to go to upgrades
echo.
set /p cmd= "C:\users\h@ck3r\hack_routine>"
set /a mon = %mon% + 1
if %cmd%= upg GOTO upgrades
goto routine

:upgrades
echo more here later
set /p=

Thank you!

Aucun commentaire:

Enregistrer un commentaire