-3

I want to make a batch adventure game (not text-based adventure) that gives you options and lets you choose to progress the story.

Problem is I don't know how to save or load progress in the game and I want to make (possibly) multiple accounts you can access to start where you left off.

I know it's possible, since I've seen it in a batch game (who's file I lost). So, anyone know to make it possible?

The Echo
  • 1
  • 3

3 Answers3

1
@echo off
:menu
cls
echo 1.Sign in
echo 2.Register
echo 3.Exit
echo.
set /p input=What would you like to do:
if %input%==1 goto log
if %input%==2 goto reg
if %input%==3 goto exit
goto menu
:reg
cls
set /p user=Enter your desired username: 
set /p pass="Enter your desired password: 
echo %pass% >> %user%.txt
:: This will prompt for a username and password and then
:: output the user variable as the name of a .txt file that contains the 
:: password
goto menu2
:log
set /p user="Enter your username: "
set /p pass="Enter your password: "
set /p password=<%user%.txt
pause >nul
:: This will check if the password entered is equal to the password in 
:: the .txt file           
if %pass% equ %password% goto menu2
goto menu
:menu2
::Enter your script here

The system is much shorter when you get rid of the comments. :)

Later on in your game you could use the same system as used in the :reg label to create a batch file with player stats and maybe an inventory in it such as set /a armor=2 and set /a sword=1 then call on that file when you want to show the player their statistics/inventory. Just an idea... Anyway, hope this helps at least a little bit.

Josh Girouard
  • 101
  • 1
  • 5
0

Im making a game and this is the login signup this is part of the code

@echo off
color f

:logsign
title whattodo?
cls
echo What will you do?
echo.
echo 1) Login
echo 2) Sign in
echo 3) Exit
echo.
set /p web=Type 1 or 2?
if "%web%"=="1" goto login
if "%web%"=="2" goto signup
if "%web%"=="3" exit

:notvalid
echo you're username is not valid.
echo.
echo please try again or sign up.
pause
cls
goto logsign

:notvalid1
echo you're password is not valid.
echo.
echo please try again or sign up.
pause
cls
goto logsign

:signup
title Sign Up
cls
echo What will be your username?
echo.
set /p username=Username:
echo %username% >%username%.bat
cls
echo What will be your password?
echo.
set /p password=Password:
echo %password%>>%username%.bat
cls
echo Go back to log in menu then log in.
pause
cls
goto logsign

:login
title login
cls
echo Let's start with name.What is it?
echo.
set /p username=Type username:
if not exist %username%.bat (goto notvalid)
pause
cls
echo Now what is your password?
echo.
set /p password=Type password:
if not exist %username%.bat (goto notvalid1)
pause
goto home

The sign up saves the user and pass in a .bat file

Markab1
  • 1
  • 2
-1

possibly you could save stats to a file named after the player profile and read off of that file to see what level they where on look around over here.
How to read file contents into a variable in a batch file?

Community
  • 1
  • 1
Luke McGregor
  • 36
  • 1
  • 5