Derp Craft batch game

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Joker4668
Posts: 4
Joined: 02 May 2013 19:57

Derp Craft batch game

#1 Post by Joker4668 » 02 May 2013 20:04

I've been coding for a few weeks now and I was wondering if someone could help me with a code.
I am currently trying to make a Text-Based Minecraft sorta thingy. I can't figure out how to make it so when you chop a tree it gives you wood and then the wood goes and adds to the Inventory Screen. If anyone could tell me what I am doing wrong I would appreciate it.

@echo off
TITLE Derp Craft
color 02

:Menu

cls

echo Derp Craft v0.1
echo ----------------
echo 1. Play
echo 2. Info
echo 3. Exit

set /p MENU=

if %MENU%==1 goto Play
if %MENU%==2 goto Info
if %MENU%==3 exit
if not %MENU%==1 goto Invalid
if not %MENU%==2 goto Invalid
if not %MENU%==3 goto Invalid

:Play

set wood=0
set rock=0
set coal=0
set diamond=0
set planks=0
set food=0

cls

echo What is your name?

set /p NAME=

echo Hello %NAME%, Welcome to Derp Craft v0.1!

pause >nul

goto Play2

:Play2

cls

echo Derp Craft v0.1
echo ----------------
echo Wood:%wood% Planks:%planks%
echo Stone:%rock% Diamond:%diamond%
echo Coal:%coal% Food:%food%
echo --------------------------
echo 1. Chop Wood
echo 2. Go Mine Stone
echo 3. Go Mine Coal
echo 4. Make Planks
echo 5. Go Diamond Mining
echo 6. Go Hunting

set /p INV=

if %INV%==1 goto Chop
if %INV%==2 goto MineStone
if %INV%==3 goto MineCoal
if %INV%==4 goto Planks
if %INV%==5 goto Diamonds
if %INV%==6 goto Hunting
if not %INV%==1 goto Invalid
if not %INV%==2 goto Invalid
if not %INV%==3 goto Invalid
if not %INV%==4 goto Invalid
if not %INV%==5 goto Invalid
if not %INV%==6 goto Invalid

:Invalid

cls

echo You entered a wrong number!

pause >nul

goto Play2

:Chop

set woodchop=8

cls

echo You go out and chop some wood.
echo You return with %woodchop% Wood.

set %wood% + %woodchop% = %wood% <----How Do I Write This Statement Correctly?

pause >nul

goto Play2

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help!

#2 Post by foxidrive » 02 May 2013 22:55

Try this:


Code: Select all

@echo off
TITLE Derp Craft
color 02

:Menu

cls

echo Derp Craft v0.1
echo ----------------
echo 1. Play
echo 2. Info
echo 3. Exit
echo.
set /p "MENU=Enter a number: "

if %MENU%==1 goto Play
if %MENU%==2 goto Info
if %MENU%==3 exit

echo.
echo Try again
ping -n 3 localhost >nul
goto :MENU


:Play

set wood=0
set rock=0
set coal=0
set diamond=0
set planks=0
set food=0

cls

set /p "NAME=What is your name?: "

echo Hello %NAME%, Welcome to Derp Craft v0.1!
echo.
ping -n 3 localhost >nul
echo bang on the keyboard to continue...
pause >nul

goto Play2

:Play2

cls

echo Derp Craft v0.1
echo ----------------
echo Wood:%wood% Planks:%planks%
echo Stone:%rock% Diamond:%diamond%
echo Coal:%coal% Food:%food%
echo --------------------------
echo 1. Chop Wood
echo 2. Go Mine Stone
echo 3. Go Mine Coal
echo 4. Make Planks
echo 5. Go Diamond Mining
echo 6. Go Hunting
echo.
set /p "INV="Enter a number: "

if %INV%==1 goto Chop
if %INV%==2 goto MineStone
if %INV%==3 goto MineCoal
if %INV%==4 goto Planks
if %INV%==5 goto Diamonds
if %INV%==6 goto Hunting

:Invalid

cls

echo You entered a wrong number!

echo Smash your forehead on the keyboard to continue...
pause >nul

goto Play2

:Chop

set woodchop=8

cls

echo You go out and chop some wood.
echo You return with %woodchop% Wood.

set /a wood=wood+woodchop


echo You now have a woodie. 
pause >nul

goto Play2

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Derp Craft batch game

#3 Post by Ranguna173 » 03 May 2013 17:37

Don't use ping, if your OS supports it use "timeout"

Code: Select all

timeout (number of seconds)

Joker4668
Posts: 4
Joined: 02 May 2013 19:57

Re: Derp Craft batch game

#4 Post by Joker4668 » 04 May 2013 13:15

Thanks so much both of you! I will be back when I screw up again! :D

Joker4668
Posts: 4
Joined: 02 May 2013 19:57

Re: Derp Craft batch game

#5 Post by Joker4668 » 06 May 2013 19:08

Hey it's me derping up again! :D
So I have been working on Derp Craft (now titled World Explorer) for a few days and I have made a crafting system thingy.
But I cannot get it to display in the Inventory Screen after I have crafted the item.


:Craft

cls

echo World Explorer v0.4
echo ---------------------
echo What would you like to craft?
echo 1. Pickaxe
echo 2. Axe
echo 3. Shovel
echo 4. Sword
echo 5. Torch
echo 6. Exit
set /p CRAFT=

if %CRAFT%==1 goto CraftPick
if %CRAFT%==2 goto CraftAxe
if %CRAFT%==3 goto CraftShovel
if %CRAFT%==4 goto CraftSword
if %CRAFT%==5 goto CraftTorch
if %CRAFT%==6 goto Play2
if not %CRAFT%==1 goto InvalidCraft
if not %CRAFT%==2 goto InvalidCraft
if not %CRAFT%==3 goto InvalidCraft
if not %CRAFT%==4 goto InvalidCraft
if not %CRAFT%==5 goto InvalidCraft
if not %CRAFT%==6 goto InvalidCraft

:InvalidCraft

cls

echo That is not a valid crafting item.
pause

goto Craft

:CraftPick

cls

if %wood% LSS 1 goto NoResources
if %stone% LSS 2 goto NoResources

set /a pickaxe1=1
set /a wood -=2
set /a stone -=3

echo You have created 1 Pickaxe.

set /a pickaxe=pickaxe+pickaxe1
pause >nul

goto Craft

:CraftAxe

cls

if %wood% LSS 1 goto NoResources
if %stone% LSS 2 goto NoResources

set /a axe1=1
set /a wood -=2
set /a stone -=3

echo You have created 1 Axe.

set /a axe=axe+axe1
pause >nul

goto Craft

:NoResources

cls

echo You do not have enough resources
echo to craft this item.
pause >nul

goto Craft

:CraftShovel

cls

if %wood% LSS 1 goto NoResources
if %stone% LSS 1 goto NoResources

set /a shovel1=1
set /a wood -=2
set /a stone -=1

echo You have created 1 Shovel.

set /a shovel=shovel+shovel1
pause >nul

goto Craft

:CraftSword

cls

if %wood% LEQ 0 goto NoResources
if %stone% LSS 1 goto NoResources

set /a sword1=1
set /a wood -=1
set /a stone -=2

echo You have created 1 Sword. <--------------I can't figure out how to make this appear down below.

set /a sword=sword+sword1
pause >nul

goto Craft

:CraftTorch

cls

if %wood% LEQ 0 goto NoResources
if %coal% LEQ 0 goto NoResources

set /a torch1=1
set /a wood -=1
set /a coal -=1

echo You have created 1 Torch.

set /a torch=torch+torch1
pause >nul

goto Craft



:Inventory

cls

echo World Explorer v0.3
echo -------------------------
echo - Pickaxes: %pickaxe% - <---------------------- Help
echo - Axes: %axe% - <---------------------- Please
echo - Shovels: %shovel% -
echo - Swords: %sword% -
echo - Torches: %torch% -
echo -------------------------
echo 1. Go Back

set /p INVSCR

if %INVSCR%==1 goto Play2
if not %INVSCR%==1 goto InvalidInv

Joker4668
Posts: 4
Joined: 02 May 2013 19:57

Re: Derp Craft batch game

#6 Post by Joker4668 » 06 May 2013 20:27

Nevermind I figured it out :D

Post Reply