Hello i have decided to give batch a go buy making a text advenutre but i need some help as i havent coded in batch before im not very good i got basic commands like "echo" "pause" and "set /p udefine=" but i am haveing trouble with ym text adventure here is the link to the paste bin wiht ym code in http://pastebin.com/cdqXCvjG
thanks for your help Zixizx
Need help with some batch.
Moderator: DosItHelp
Re: Need help with some batch.
You should not write this kind of spaghetti code. Call subroutines instead.
Have a look at that
In main: By goto :eof it jums to the end of file and ends the batch
In subroutines: By goto :eof it jumps back to the point where the subroutine was called.
Hope that helps
aGerman
Have a look at that
Code: Select all
@echo off
color 0f
title An Adventure Through Text
:top
cls
echo ***************************************************************
echo.
echo Your Adventure Begines Here.
echo.
echo ***************************************************************
echo.
echo You Have Started Your Adventure What Would You Like to Do?
:MainLoop
echo [1] Go To The Pub.
echo [2] Go To The Woods.
echo [3] Go Home.
echo.
echo [e] Exit
echo.
echo ***************************************************************
echo Enter The Number Of The Action You Wish To Choose.
echo.
set "udefine="
set /p udefine=
echo.
echo ***************************************************************
if "%udefine%"=="1" call :pub
if "%udefine%"=="2" call :woods
if "%udefine%"=="3" call :home
if /i "%udefine%"=="e" goto :eof
goto MainLoop
:pub
cls
echo You Go To The Pub.
echo.
echo You Buy A Drink And Have A Meal You Feel Refreshed.
pause
cls
goto :eof
:woods
cls
echo You Enter The Woods And You Find Some Gold,
echo You Take It Back To The Town,
echo And earn your Riches.
pause
cls
echo *****************************
echo You Have Returned To The Town Center
echo What Would You Like to Do?
echo.
goto :eof
:home
cls
echo *****************************
echo You're at home now
echo What Would You Like to Do?
echo.
goto :eof
In main: By goto :eof it jums to the end of file and ends the batch
In subroutines: By goto :eof it jumps back to the point where the subroutine was called.
Hope that helps
aGerman
Re: Need help with some batch.
You my freind are a ledgend thank you so much