Batch Coding Help
Moderator: DosItHelp
-
- Posts: 11
- Joined: 02 May 2015 00:13
Batch Coding Help
I have not done all the coding, but the bits I do have are not working correctly. I am using word pad, and I wanted to know if someone could post the corrected version of the code below so I could fix my mistakes.
@echo off
@title Dungeon
:plot
echo You awaken in a dark room.
echo A male voice from the other side of the room sayes
echo "Why don't you start the fire, It's gettin mighty cold in here."
echo You feel around the floor and find a small pile of wood.
echo You continue to crawl around and you bump into a small stone wall.
echo You stand up to realize that it's a fire pit.
echo You put a log into it and then the other man sets it on fire.
echo The man on the other side of the room sayes that he's a Builder.
echo He can build you suplies if you get the materials.
echo You look around and see leather straps, iron, and a wood.
:1st_problem
echo Press 1 to craft a knife
echo Press 2 to craft bow
SET/P"problem= 1Choice"=
If"%problem1%"=="1"then goto plot 2
If"%problem1%"=="2"then goto plot 3
cls
:plot2
echo "Oh", he remarks,"I would have made a bow and some arrows, although you strike me as more of a "hand to hand" guy.
echo After a while the man hands you a large, light weight knife.
echo You turn over the knife in your hands, and see it has a deep groove running the length of the blade.
echo The man sayes, as if reading your mind,"The groove is so the blood runs through the knife."
echo "The knife will do more damage to your targets that way." He explains.
:2nd_problem
echo A large cheetah jumps in though the door and swipes at you!
echo Press 1 to stab the cheetah
echo Press 2 to try to talk to the cheetah
SET/p"problem= 2Choice"=
If"%problem2%"=="1"then goto plot 4
If"%problem2%"=="2"then goto plot 5
cls
:plot3
echo "Ah" he sayes,"a true hunters weapon, in fact I got enough materials I am going to make you a few arrows aswell.
echo After a while he hands you a hunting bow, and a small quivver with ten arrows inside.
echo "The arrows have a grooved tips so they will puncture deeper into you prey."
:3rd_problem
echo Through a window you spot a large cheetah walking around the edge of the forest.
echo Press 1 to shoot at the cheetah
echo Press 2 to yell "Hey" at the cheetah
SET/p"problem= 3Choice"=
If"%problem3%"=="1"then goto plot 7
If"%problem3%"=="2"then goto plot 6
cls
:plot4
echo The knife cleanly stabs into cheetah ripping a large hole in its flesh.
echo The cat yowls in pain, and flops on the ground dead.
echo "Wow", He exclaims, "Now we got some meat!"
echo "Now, if you want I could get that a-cookin,or, if you like I could make you some armor."
:4th_problem
echo Press 1 to make the cooked meat
echo Press 2 to make the armor
SET/p"problem= 4Choice"=
If"%problem4%"=="1"then goto plot 8
If"%problem4%"=="2"then goto plot 9
cls
:plot5
echo "Hey", you yell.
echo "Oh, hey." the cheetah replies.
echo "I want to kill you" the cheetah sayes.
echo "So I am going to kill you, now. Is that ok?" he pauses,"Cause I am going to do it anyways"
:5th_problem
echo Press 1 to stab the cheetah
echo Press 2 to not stab the cheetah (although you'd be really stupid do do this)
SET/p"problem= 5Choice"=
If"%problem5%"=="1" then goto plot 4
If"%problem5%"=="2" then goto plot 100
cls
:plot6
echo "Hey", you yell.
echo "Oh, hey." the cheetah replies.
echo "I want to kill you" the cheetah sayes.
echo "So I am going to kill you, now. Is that ok?" he pauses,"Cause I am going to do it anyways"
:6th_problem
echo Press 1 to shoot arrow at the cheetah
echo Press 2 to not shoot the cheetah (although you'd be really stupid do do this)
SET/p"problem= 6Choice"=
If"%problem6%"=="1" then goto plot 7
If"%problem6%"=="2" then goto plot 100
cls
:plot7
echo The arrow stabs into cheetah's head.
echo The cat yowls in pain, and flops on the ground dead.
echo "Wow", He exclaims, "Now we got some meat!"
echo "Now, if you want I could get that a-cookin,or, if you like I could make you some armor."
:7th_problem
echo Press 1 to make the cooked meat
echo Press 2 to make the armor
SET/p"problem= 7Choice"=
If"%problem7%"=="1"then goto plot 8
If"%problem7%"=="2"then goto plot 9
@echo off
@title Dungeon
:plot
echo You awaken in a dark room.
echo A male voice from the other side of the room sayes
echo "Why don't you start the fire, It's gettin mighty cold in here."
echo You feel around the floor and find a small pile of wood.
echo You continue to crawl around and you bump into a small stone wall.
echo You stand up to realize that it's a fire pit.
echo You put a log into it and then the other man sets it on fire.
echo The man on the other side of the room sayes that he's a Builder.
echo He can build you suplies if you get the materials.
echo You look around and see leather straps, iron, and a wood.
:1st_problem
echo Press 1 to craft a knife
echo Press 2 to craft bow
SET/P"problem= 1Choice"=
If"%problem1%"=="1"then goto plot 2
If"%problem1%"=="2"then goto plot 3
cls
:plot2
echo "Oh", he remarks,"I would have made a bow and some arrows, although you strike me as more of a "hand to hand" guy.
echo After a while the man hands you a large, light weight knife.
echo You turn over the knife in your hands, and see it has a deep groove running the length of the blade.
echo The man sayes, as if reading your mind,"The groove is so the blood runs through the knife."
echo "The knife will do more damage to your targets that way." He explains.
:2nd_problem
echo A large cheetah jumps in though the door and swipes at you!
echo Press 1 to stab the cheetah
echo Press 2 to try to talk to the cheetah
SET/p"problem= 2Choice"=
If"%problem2%"=="1"then goto plot 4
If"%problem2%"=="2"then goto plot 5
cls
:plot3
echo "Ah" he sayes,"a true hunters weapon, in fact I got enough materials I am going to make you a few arrows aswell.
echo After a while he hands you a hunting bow, and a small quivver with ten arrows inside.
echo "The arrows have a grooved tips so they will puncture deeper into you prey."
:3rd_problem
echo Through a window you spot a large cheetah walking around the edge of the forest.
echo Press 1 to shoot at the cheetah
echo Press 2 to yell "Hey" at the cheetah
SET/p"problem= 3Choice"=
If"%problem3%"=="1"then goto plot 7
If"%problem3%"=="2"then goto plot 6
cls
:plot4
echo The knife cleanly stabs into cheetah ripping a large hole in its flesh.
echo The cat yowls in pain, and flops on the ground dead.
echo "Wow", He exclaims, "Now we got some meat!"
echo "Now, if you want I could get that a-cookin,or, if you like I could make you some armor."
:4th_problem
echo Press 1 to make the cooked meat
echo Press 2 to make the armor
SET/p"problem= 4Choice"=
If"%problem4%"=="1"then goto plot 8
If"%problem4%"=="2"then goto plot 9
cls
:plot5
echo "Hey", you yell.
echo "Oh, hey." the cheetah replies.
echo "I want to kill you" the cheetah sayes.
echo "So I am going to kill you, now. Is that ok?" he pauses,"Cause I am going to do it anyways"
:5th_problem
echo Press 1 to stab the cheetah
echo Press 2 to not stab the cheetah (although you'd be really stupid do do this)
SET/p"problem= 5Choice"=
If"%problem5%"=="1" then goto plot 4
If"%problem5%"=="2" then goto plot 100
cls
:plot6
echo "Hey", you yell.
echo "Oh, hey." the cheetah replies.
echo "I want to kill you" the cheetah sayes.
echo "So I am going to kill you, now. Is that ok?" he pauses,"Cause I am going to do it anyways"
:6th_problem
echo Press 1 to shoot arrow at the cheetah
echo Press 2 to not shoot the cheetah (although you'd be really stupid do do this)
SET/p"problem= 6Choice"=
If"%problem6%"=="1" then goto plot 7
If"%problem6%"=="2" then goto plot 100
cls
:plot7
echo The arrow stabs into cheetah's head.
echo The cat yowls in pain, and flops on the ground dead.
echo "Wow", He exclaims, "Now we got some meat!"
echo "Now, if you want I could get that a-cookin,or, if you like I could make you some armor."
:7th_problem
echo Press 1 to make the cooked meat
echo Press 2 to make the armor
SET/p"problem= 7Choice"=
If"%problem7%"=="1"then goto plot 8
If"%problem7%"=="2"then goto plot 9
Re: Batch Coding Help
The IF command does not use THEN.
IF string1==string2 command
IF string1==string2 command
-
- Posts: 11
- Joined: 02 May 2015 00:13
Re: Batch Coding Help
so I just remove the thens and it'll work?
Re: Batch Coding Help
Also:
There should be space between IF and "%problem1%"...
There should be no space between 'plot' and '2'.
Saso
Code: Select all
If"%problem1%"=="1"then goto plot 2
There should be space between IF and "%problem1%"...
There should be no space between 'plot' and '2'.
Saso
-
- Posts: 11
- Joined: 02 May 2015 00:13
Re: Batch Coding Help
Here is a section of the coding that I have, with all the changes that you guys said. But It still doesn't work!! Please try it in your notepad.
:plot
echo You awaken in a dark room.
echo A male voice from the other side of the room says
echo "Why don't you start the fire, It's gettin mighty cold in here."
echo You feel around the floor and find a small pile of wood.
echo You continue to crawl around and you bump into a small stone wall.
echo You stand up to realize that it's a fire pit.
echo You put a log into it and then the other man sets it on fire.
echo The man on the other side of the room says that he's a Builder.
echo He can build you supplies if you get the materials.
echo You look around and see leather straps, iron, and a wood.
:1st_problem
echo Press 1 to craft a knife
echo Press 2 to craft bow
SET/P"problem= 1Choice"=
If "%problem1%"=="1" goto plot2
If "%problem1%"=="2" goto plot3
cls
:plot2
echo "Oh", he remarks,"I would have made a bow and some arrows, although you strike
echo me as more of a "hand to hand" guy.
echo After a while the man hands you a large, light weight knife.
echo You turn over the knife in your hands, and see it has a deep groove running the length of the blade.
echo The man sayes, as if reading your mind,"The groove is so the blood runs through the knife."
echo "The knife will do more damage to your targets that way." He explains.
:2nd_problem
echo A large cheetah jumps in though the door and swipes at you!
echo Press 1 to stab the cheetah
echo Press 2 to try to talk to the cheetah
SET/p"problem= 2Choice"=
If "%problem2%"=="1" goto plot4
If "%problem2%"=="2" goto plot5
cls
:plot3
echo "Ah" he says,"a true hunters weapon, in fact I got enough materials I am going to make you a few arrows aswell.
echo After a while he hands you a hunting bow, and a small quiver with ten arrows inside.
echo "The arrows have a grooved tips so they will puncture deeper into you prey."
:3rd_problem
echo Through a window you spot a large cheetah walking around the edge of the forest.
echo Press 1 to shoot at the cheetah
echo Press 2 to yell "Hey" at the cheetah
SET/p"problem= 3Choice"=
If "%problem3%"=="1" goto plot7
If "%problem3%"=="2" goto plot6
cls
:plot4
echo The knife cleanly stabs into cheetah ripping a large hole in its flesh.
echo The cat yowls in pain, and flops on the ground dead.
echo "Wow", He exclaims, "Now we got some meat!"
echo "Now, if you want I could get that a-cookin,or, if you like I could make you some armor."
:4th_problem
echo Press 1 to make the cooked meat
echo Press 2 to make the armor
SET/p"problem= 4Choice"=
If "%problem4%"=="1" goto plot8
If "%problem4%"=="2" goto plot9
:plot
echo You awaken in a dark room.
echo A male voice from the other side of the room says
echo "Why don't you start the fire, It's gettin mighty cold in here."
echo You feel around the floor and find a small pile of wood.
echo You continue to crawl around and you bump into a small stone wall.
echo You stand up to realize that it's a fire pit.
echo You put a log into it and then the other man sets it on fire.
echo The man on the other side of the room says that he's a Builder.
echo He can build you supplies if you get the materials.
echo You look around and see leather straps, iron, and a wood.
:1st_problem
echo Press 1 to craft a knife
echo Press 2 to craft bow
SET/P"problem= 1Choice"=
If "%problem1%"=="1" goto plot2
If "%problem1%"=="2" goto plot3
cls
:plot2
echo "Oh", he remarks,"I would have made a bow and some arrows, although you strike
echo me as more of a "hand to hand" guy.
echo After a while the man hands you a large, light weight knife.
echo You turn over the knife in your hands, and see it has a deep groove running the length of the blade.
echo The man sayes, as if reading your mind,"The groove is so the blood runs through the knife."
echo "The knife will do more damage to your targets that way." He explains.
:2nd_problem
echo A large cheetah jumps in though the door and swipes at you!
echo Press 1 to stab the cheetah
echo Press 2 to try to talk to the cheetah
SET/p"problem= 2Choice"=
If "%problem2%"=="1" goto plot4
If "%problem2%"=="2" goto plot5
cls
:plot3
echo "Ah" he says,"a true hunters weapon, in fact I got enough materials I am going to make you a few arrows aswell.
echo After a while he hands you a hunting bow, and a small quiver with ten arrows inside.
echo "The arrows have a grooved tips so they will puncture deeper into you prey."
:3rd_problem
echo Through a window you spot a large cheetah walking around the edge of the forest.
echo Press 1 to shoot at the cheetah
echo Press 2 to yell "Hey" at the cheetah
SET/p"problem= 3Choice"=
If "%problem3%"=="1" goto plot7
If "%problem3%"=="2" goto plot6
cls
:plot4
echo The knife cleanly stabs into cheetah ripping a large hole in its flesh.
echo The cat yowls in pain, and flops on the ground dead.
echo "Wow", He exclaims, "Now we got some meat!"
echo "Now, if you want I could get that a-cookin,or, if you like I could make you some armor."
:4th_problem
echo Press 1 to make the cooked meat
echo Press 2 to make the armor
SET/p"problem= 4Choice"=
If "%problem4%"=="1" goto plot8
If "%problem4%"=="2" goto plot9
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Coding Help
Code: Select all
SET/P"problem= 1Choice"=
In order to set the problem1 variable and give the prompt "Choice," you need to say
Code: Select all
set /p "problem1=Choice"=
And the three other prompts need to be corrected in the same way.
-
- Posts: 11
- Joined: 02 May 2015 00:13
Re: Batch Coding Help
Code: Select all
SET/p"problem2= Choice"=
Do I need a space between the = and the word choice
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Coding Help
Any spaces after the first = but before the word Choice will be ignored. Any spaces between the word Choice and the " will be echoed to the screen.
-
- Posts: 11
- Joined: 02 May 2015 00:13
Re: Batch Coding Help
Now all that is broken is the code goto plot3, so thanks for the help.
So is there anything specifically wrong with the plot3?
:plot3
cls
color 0E
echo "Ah" he says,"a true hunters weapon, in fact I got enough materials.
echo I am going to make you a few arrows as well.
echo After a while he hands you a hunting bow.
echo and a small quiver with ten arrows inside.
echo "The arrows have a grooved tips so they will go deeper into you prey."
:3rd_problem
echo Through a window you spot a large cheetah walking around the edge of the forest.
echo Press 1 to shoot at the cheetah
echo Press 2 to yell "Hey" at the cheetah
SET/p"problem3= Choice"=
If "%problem3%"=="1" goto plot7
If "%problem3%"=="2" goto plot6
So is there anything specifically wrong with the plot3?
:plot3
cls
color 0E
echo "Ah" he says,"a true hunters weapon, in fact I got enough materials.
echo I am going to make you a few arrows as well.
echo After a while he hands you a hunting bow.
echo and a small quiver with ten arrows inside.
echo "The arrows have a grooved tips so they will go deeper into you prey."
:3rd_problem
echo Through a window you spot a large cheetah walking around the edge of the forest.
echo Press 1 to shoot at the cheetah
echo Press 2 to yell "Hey" at the cheetah
SET/p"problem3= Choice"=
If "%problem3%"=="1" goto plot7
If "%problem3%"=="2" goto plot6
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Coding Help
It works fine for me. What specific problem are you having? I notice that you've reversed plot6 and plot7 in the choices; that might be something.
-
- Posts: 11
- Joined: 02 May 2015 00:13
Re: Batch Coding Help
What specific problem are you having?
For me the goto command in the first plot is not actually taking me to plot3.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Coding Help
Assuming you corrected the set /p command so that you're actually setting the problem1 variable, you're going to a label called plot3, and you actually have a label called plot3, there's no reason it shouldn't work.
-
- Posts: 11
- Joined: 02 May 2015 00:13
Re: Batch Coding Help
OMG, I am so dumb... I forgot to add the space so it was going to ,gotoplot3, instead of ,plot3. *facepalm
Well thanks you all. I now have enough knowledge to finish making my game. I will post the finished code on this forum page, if you want to play when I am done.
Well thanks you all. I now have enough knowledge to finish making my game. I will post the finished code on this forum page, if you want to play when I am done.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Coding Help
Sweet.
Just one recommendation from a usability perspective: change to because "Choice: 2" looks way better than "Choice2"
Just one recommendation from a usability perspective: change
Code: Select all
set /p "problem1=Choice"=
Code: Select all
set /p "problem1=Choice: "=
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch Coding Help
Ane by "one" I apparently mean "two" recommendations... >_>
Keep in mind that the default command prompt window size is 80 characters wide. Some of your lines are considerably longer than that, so either resize the window with the mode con cols command or rearrange your words.
Keep in mind that the default command prompt window size is 80 characters wide. Some of your lines are considerably longer than that, so either resize the window with the mode con cols command or rearrange your words.