So I decided to learn Batch and I'm trying to program a small RPG/adventure game that is narrative driven for the RPG snuffs at the office. So I'm having a few problems and have a few questions.
@echo off
color F0
title The Kingdom of Kovalor
type Titlescreen.txt
pause >nul
goto MainMenu
:MainMenu
cls
type mainmenu.txt
echo.
echo Type in option and press Enter.
Set /p menu=
if "%menu%" equ "new game" goto NewGame
if %menu% equ credits goto Credits
if "%menu%" equ "load game" goto LGame
echo Try again.
if %menu% neq new game goto MainMenu
if %menu% neq credits goto MainMenu
if %menu% neq load game goto MainMenu
pause >nul
:Credits
cls
echo Made by XXXXXXXXX
echo.
echo.
echo Press any key to return to Main Menu.
pause >nul
goto MainMenu
:NewGame
cls
echo What is your name, adventurer?
echo.
Set /p name=
echo.
echo %name%, are you a man or woman?
echo.
Set /p sex=
goto Stats
:SaveGame
@echo @ECHO OFF > save%name%.bat
@echo SET name=%name% >> save%name%.bat
@echo SET sex=%sex% >> save%name%.bat
@echo SET playerHP=%playerHP% >> save%name%.bat
@echo SET playerATK=%playerATK% >> save%name%.bat
@echo SET playerDEF=%playerDEF% >> save%name%.bat
@echo SET playerLVL=%playerLVL% >> save%name%.bat
echo.
echo Game saved correctly.
echo Press any key to continue.
pause >n
exit
:LGame
cls
echo.
echo What's your name?
echo.
Set /p name=
echo Load successful.
pause >nul
exit
:Stats
cls
set /a playerHP = 25
set /a playerATK = 5
set /a playerDEF = 0
set /a playerLVL = 1
echo These are your stats.
echo Health, when it depletes, you die. %playerHP%
echo Attack. The ammount of damage you deal. %playerATK%
echo Defense. Armor which reduces the damage you take. %playerDEF%
echo Level dictates the experience you have as an adventurer. %playerLVL%
echo You can improve these as you go.
echo For now you have no weapons nor armor.
pause >nul
if %sex% equ man goto StartAdventureMan
if %sex% equ woman goto StartAdventureWoman
:StartAdventureMan
cls
echo Kovalor wasn't always like this. There was a time where one could
echo walk around town without being disturbed. The so-called king has
echo placed himself on the throne with the help of twisted creatures.
echo.
echo TUTORIAL *Press Space Bar to continue narrative.*
pause >nul
echo.
echo There have been talks about a coup or silent assasinations but
echo nothing has been proven to be but a rumor.
echo Nonetheless, the King must fall.
pause >nul
echo.
echo %name% got out of bed that morning with a headache born from heavy
echo drinking the previous night. He got dressed and left for the tool
echo shed outside his house. The cold early-spring air snipping at his
echo bare arms. His best hoe laid on the floor.
pause >nul
goto PickUpHoe
:StartAdventureWoman
cls
echo Kovalor wasn't always like this. There was a time where one could
echo walk around town without being disturbed. The so-called king has
echo placed himself on the throne with the help of twisted creatures.
echo.
echo TUTORIAL *Press Space Bar to continue narrative.*
pause >nul
echo.
echo There have been talks about a coup or silent assasinations but
echo nothing has been proven to be but a rumor.
echo Nonetheless, the King must fall.
pause >nul
echo.
echo %name% got out of bed that morning with a headache born from heavy
echo drinking the previous night. She got dressed and left for the tool
echo shed outside her house. The cold early-spring air snipping at her
echo bare arms. Her best hoe laid on the floor.
pause >nul
goto PickUpHoe
:PickUpHoe
echo.
echo TUTORIAL *Type take followed by an object and press enter in order
echo to pick it up and add it to your inventory.*
set /p action1=
if "%action1%" neq "take hoe" echo TUTORIAL *Type take hoe followed by Enter.*
goto PickUpHoe
echo *Picked up hoe.*
pause >nul
goto SaveTutorial
:SaveTutorial
echo.
echo TUTORIAL *You can save progress whenever you can type by typing Save Game.*
echo *Try saving now.*
Set /p action2=
if "%action2%" equ "Save Game" goto SaveGame
if "%action2%" neq "Save Game" goto SaveTutorial
pause >nul
exit
As you may notice, this isn't really too far along. And as I'm adding code I'm testing it. So the thing is that I can't get the LGame method (I don't know how you call that in Batch, complete beginner at programming in general so bear with me). For the moment it's just supposed to print the message, but if I run it it just crashes. Everything else works correctly.
Now for questions.
- How could I make it so when you save the game, you go back to the point where you were?
- When I get LGame to work, how exactly would you call the save file?
And, if possible, some pointers on an inventory system and a pause menu that you can bring up at any time and then go back to the screen you were in before. Any pointer in general?