Good luck with that minecraft project. Batch is really not made for advanced scripting: you should try C++ instead! It even compiles into an EXE
As for tutorials, I have a really heavy black and white book called MS DOS 6.0 published in the 20th century that dedicates 300 pages to the batch syntax. I doubt that many still have it though, so an online tutorial might be better
Offline
LS97 wrote:
Good luck with that minecraft project. Batch is really not made for advanced scripting: you should try C++ instead! It even compiles into an EXE
![]()
As for tutorials, I have a really heavy black and white book called MS DOS 6.0 published in the 20th century that dedicates 300 pages to the batch syntax. I doubt that many still have it though, so an online tutorial might be better![]()
Thanks!
I am learning Java so no need for C++ YET. I found a number of tutorials for MSDOS 6.0
but they where for windows 95. XD Has the syntax changed at all?
Offline
poopo wrote:
LS97 wrote:
Good luck with that minecraft project. Batch is really not made for advanced scripting: you should try C++ instead! It even compiles into an EXE
![]()
As for tutorials, I have a really heavy black and white book called MS DOS 6.0 published in the 20th century that dedicates 300 pages to the batch syntax. I doubt that many still have it though, so an online tutorial might be better![]()
Thanks!
I am learning Java so no need for C++ YET. I found a number of tutorials for MSDOS 6.0
but they where for windows 95. XD Has the syntax changed at all?
Some commands have been added (such as shutdown support which was not possible in older PCs) and some have been removed (such as dosshell since we have win explorer).
Offline
Well, there's the Wikipedia page of DOS commands, and there's also this page which explains variables, ifs, pipes/redirection, and things like that.
Offline
Well, I suggest experimenting with multiple commands. Like the ECHO and SET commands:
echo @off :: Turns off the echo commands so it doesn't show "echo Welcome!" then "Welcome!" it only shows "Welcome!" echo Welcome! :: Echo command SET /P name=Hello! What is your name? :: SET sets a variable ( SET var=value ) the /P is basically the "ASK 'question' and wait" in Scratch echo Hello %name%! :: %var% just shows the value of 'var' or in this case 'name'
Batch is not something to program in, especially games and making Minecraft in it would be extremely hard, harder than in Scratch. Though I did make a small game in it, though it is VERY basic.
@echo off SET level=1 SET /A maxEXP=%level%*5 SET exp=0 SET /A maxHP=%level%*10 SET health=%maxHP% SET lives=2 SET gold=0 SET /A mhp=%level%*5 SET /P name=Hello! What is your name? GOTO START :START ECHO Hello %name%! Welcome to this game! ECHO Type HELP to learn more about the commands. GOTO GETCMD :BACKFROMTHEDEAD IF %lives% LEQ 0 GOTO END SET /A lives=%lives% - 1 ECHO You have been brought back from the dead. Someone walks up to you and says "You have %lives% more time(s) to die." GOTO GETCMD :GETCMD IF %exp% GEQ %maxEXP% ( SET /A level=%level%+1 ECHO You leveled up! You are now level %level%! SET /A exp=%exp%-%maxEXP% SET /A maxHP=%level%*10 SET /A mhp=%level%*5 SET /A maxEXP=%level%*5 ) SET /P cmd=Command: GOTO RUNCMD :RUNCMD IF /I %cmd%==HELP GOTO HELP IF /I %cmd%==QUIT GOTO END IF /I %cmd%==EXPLORE GOTO EXPLORE IF /I %cmd%==SHOP GOTO SHOP IF /I %cmd%==INFO GOTO DETAILS ECHO No command %cmd% & GOTO GETCMD :HELP ECHO Command : Description ECHO HELP : Shows help page. ECHO EXPLORE : You can explore the world. ECHO SHOP : Shop for items to increase the chance of your survival ECHO INFO : Displays info about your character. ECHO QUIT : Exit the game. GOTO GETCMD :RANDOM set ran=%random:~-1% GOTO %return% :EXPLORE SET return=EXPLORE2 GOTO RANDOM :EXPLORE2 IF %ran% == 0 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD IF %ran% == 1 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD IF %ran% == 2 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD ::IF %ran% == 3 GOTO ATTACKED & GOTO GETCMD ::IF %ran% == 4 GOTO ATTACKED & GOTO GETCMD ::IF %ran% == 5 GOTO ATTACKED & GOTO GETCMD ::IF %ran% == 6 GOTO ATTACKED & GOTO GETCMD IF %ran% == 7 GOTO ATTACKED & GOTO GETCMD IF %ran% == 8 GOTO ATTACKED & GOTO GETCMD IF %ran% == 9 GOTO ATTACKED & GOTO GETCMD ECHO You found nothing while exploring. GOTO GETCMD :DETAILS ECHO Name : %name% ECHO Health: %health%/%maxHP% ECHO Level : %level% ECHO Exp : %exp%/%maxEXP% ECHO Gold : %gold% GOTO GETCMD :SHOP ECHO Item ID : Price : Item Details ECHO 0 : 0 : Leave Shop ECHO 1 : 1 : Health Potion - Restores HP ECHO 2 : 2 : Monster Attraction - Attracts a monster SET /P cmd=What would you like to buy? IF %cmd%==0 ECHO Come again! & GOTO GETCMD IF %cmd%==1 ( IF %gold% LEQ 0 ECHO Not enough money! & GOTO GETCMD SET /A gold=%gold% - 1 ECHO Health restored! SET health=%maxHP% GOTO GETCMD ) IF %cmd%==2 ( IF %gold% LEQ 1 ECHO Not enough money! & GOTO GETCMD SET /A gold=%gold%-2 ECHO A monster appears! GOTO ATTACKED3 & GOTO GETCMD ) IF %cmd%==3 ( IF %gold% LEQ 2 ECHO Not enough money! & GOTO GETCMD SET /A gold=%gold%-3 SET /A lives=%lives%+1 ECHO You have gained a life! GOTO GETCMD ) ECHO No such item! GOTO GETCMD :ATTACKED SET return=ATTACKED2 GOTO RANDOM :ATTACKED2 ECHO You were attacked by a monster and lost %ran% health! SET /A health= %health% - %ran% IF %health% LEQ 0 ECHO You died! & GOTO BACKFROMTHEDEAD ECHO You have %health% left! SET return=ATTACKED3 GOTO RANDOM :ATTACKED3 ECHO You hit the monster and made him loose %ran% health! SET /A mhp=%mhp% - %ran% IF %mhp% LEQ 0 ECHO You killed the monster and found one gold piece and gained some expierence from the fight! & SET mhp=5 & SET /A gold=%gold% + 1 & SET /A exp=%exp% + 1 & GOTO GETCMD SET return=ATTACKED2 GOTO RANDOM :END ECHO The End!
The battle system is not very good, sadly. Though it is a start, especially for something I made in about four hours over two days.
Hopefully that can help you get started on learning Batch.
Offline
I'm trying to learn this too.
The "help" command is helpful and type "/?" after any command to learn what it does. Wiki Page.
Here's a program I quickly came up with, it's not very good but:
@ECHO off Title Options color 3 ECHO Welcome to system commands! Choice /c LSIRHC /n /m "L=Log off, S=Shutdown, I=Instant Shut Down, R=Restart, H=Hibernate, C=Close All Programs" If %ERRORLEVEL%==1 shutdown /l If %ERRORLEVEL%==2 shutdown /s If %ERRORLEVEL%==3 shutdown /p If %ERRORLEVEL%==4 shutdown /r If %ERRORLEVEL%==5 shutdown /h If %ERRORLEVEL%==6 shutdown /f Exit
Offline
this might be useful for calling other batch files:
test1.bat:
Code:
@echo off set /p name=What is your name? test2 %name%test2.bat:
Code:
@echo off echo Hello %1%! pause
note that these are two seperate batch files
Offline
Servine wrote:
Im more of a VBS guy, but:
Code:
ECHO Trolls be trolling. GOTO WAFFLEMAN ::WAFLLEMAN ECHO U MAD BRO? pauseI literally just thought of that on the top of my head.
wrong. this was meant for the 'Batch' topic
Offline
Magnie wrote:
Well, I suggest experimenting with multiple commands. Like the ECHO and SET commands:
Code:
echo @off :: Turns off the echo commands so it doesn't show "echo Welcome!" then "Welcome!" it only shows "Welcome!" echo Welcome! :: Echo command SET /P name=Hello! What is your name? :: SET sets a variable ( SET var=value ) the /P is basically the "ASK 'question' and wait" in Scratch echo Hello %name%! :: %var% just shows the value of 'var' or in this case 'name'Batch is not something to program in, especially games and making Minecraft in it would be extremely hard, harder than in Scratch. Though I did make a small game in it, though it is VERY basic.
Code:
@echo off SET level=1 SET /A maxEXP=%level%*5 SET exp=0 SET /A maxHP=%level%*10 SET health=%maxHP% SET lives=2 SET gold=0 SET /A mhp=%level%*5 SET /P name=Hello! What is your name? GOTO START :START ECHO Hello %name%! Welcome to this game! ECHO Type HELP to learn more about the commands. GOTO GETCMD :BACKFROMTHEDEAD IF %lives% LEQ 0 GOTO END SET /A lives=%lives% - 1 ECHO You have been brought back from the dead. Someone walks up to you and says "You have %lives% more time(s) to die." GOTO GETCMD :GETCMD IF %exp% GEQ %maxEXP% ( SET /A level=%level%+1 ECHO You leveled up! You are now level %level%! SET /A exp=%exp%-%maxEXP% SET /A maxHP=%level%*10 SET /A mhp=%level%*5 SET /A maxEXP=%level%*5 ) SET /P cmd=Command: GOTO RUNCMD :RUNCMD IF /I %cmd%==HELP GOTO HELP IF /I %cmd%==QUIT GOTO END IF /I %cmd%==EXPLORE GOTO EXPLORE IF /I %cmd%==SHOP GOTO SHOP IF /I %cmd%==INFO GOTO DETAILS ECHO No command %cmd% & GOTO GETCMD :HELP ECHO Command : Description ECHO HELP : Shows help page. ECHO EXPLORE : You can explore the world. ECHO SHOP : Shop for items to increase the chance of your survival ECHO INFO : Displays info about your character. ECHO QUIT : Exit the game. GOTO GETCMD :RANDOM set ran=%random:~-1% GOTO %return% :EXPLORE SET return=EXPLORE2 GOTO RANDOM :EXPLORE2 IF %ran% == 0 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD IF %ran% == 1 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD IF %ran% == 2 SET /A gold=%gold% + 1 & ECHO You found a gold piece! & GOTO GETCMD ::IF %ran% == 3 GOTO ATTACKED & GOTO GETCMD ::IF %ran% == 4 GOTO ATTACKED & GOTO GETCMD ::IF %ran% == 5 GOTO ATTACKED & GOTO GETCMD ::IF %ran% == 6 GOTO ATTACKED & GOTO GETCMD IF %ran% == 7 GOTO ATTACKED & GOTO GETCMD IF %ran% == 8 GOTO ATTACKED & GOTO GETCMD IF %ran% == 9 GOTO ATTACKED & GOTO GETCMD ECHO You found nothing while exploring. GOTO GETCMD :DETAILS ECHO Name : %name% ECHO Health: %health%/%maxHP% ECHO Level : %level% ECHO Exp : %exp%/%maxEXP% ECHO Gold : %gold% GOTO GETCMD :SHOP ECHO Item ID : Price : Item Details ECHO 0 : 0 : Leave Shop ECHO 1 : 1 : Health Potion - Restores HP ECHO 2 : 2 : Monster Attraction - Attracts a monster SET /P cmd=What would you like to buy? IF %cmd%==0 ECHO Come again! & GOTO GETCMD IF %cmd%==1 ( IF %gold% LEQ 0 ECHO Not enough money! & GOTO GETCMD SET /A gold=%gold% - 1 ECHO Health restored! SET health=%maxHP% GOTO GETCMD ) IF %cmd%==2 ( IF %gold% LEQ 1 ECHO Not enough money! & GOTO GETCMD SET /A gold=%gold%-2 ECHO A monster appears! GOTO ATTACKED3 & GOTO GETCMD ) IF %cmd%==3 ( IF %gold% LEQ 2 ECHO Not enough money! & GOTO GETCMD SET /A gold=%gold%-3 SET /A lives=%lives%+1 ECHO You have gained a life! GOTO GETCMD ) ECHO No such item! GOTO GETCMD :ATTACKED SET return=ATTACKED2 GOTO RANDOM :ATTACKED2 ECHO You were attacked by a monster and lost %ran% health! SET /A health= %health% - %ran% IF %health% LEQ 0 ECHO You died! & GOTO BACKFROMTHEDEAD ECHO You have %health% left! SET return=ATTACKED3 GOTO RANDOM :ATTACKED3 ECHO You hit the monster and made him loose %ran% health! SET /A mhp=%mhp% - %ran% IF %mhp% LEQ 0 ECHO You killed the monster and found one gold piece and gained some expierence from the fight! & SET mhp=5 & SET /A gold=%gold% + 1 & SET /A exp=%exp% + 1 & GOTO GETCMD SET return=ATTACKED2 GOTO RANDOM :END ECHO The End!The battle system is not very good, sadly. Though it is a start, especially for something I made in about four hours over two days.
Hopefully that can help you get started on learning Batch.![]()
Cool game good job on it
Offline
Thank you.
Offline