Page 1 of 1

Saving progress/game

Posted: 03 Jan 2012 10:30
by silent
Hi,i decided to make a Hacking simulator,like HackTheGame,and i want to do a saving thing.So if player will do 5 missions etc he will write save and it will save his progress to other file.

Code: Select all

::at start of program user gives his nickname
echo Write your nickname

set /p nickname=

if %nickname% ==goto start

::Now the saving command

set /p save=

if %save% == I DONT KNOW WHAT TO WRITE HERE

And it would save to a file with the username,so the user will be able to load his save only when he logged (in the program) with same nickname as is saved in the file.

Re: Saving progress/game

Posted: 03 Jan 2012 10:45
by silent
and to load the save user needs to use command load

Re: Saving progress/game

Posted: 04 Jan 2012 10:53
by silent
I got an idea,but i dont know if it will work,i thought about IF EXISTS but it would search for something that exists in a file,like IF EXISTS "GameSettings.txt" "Level=2" "Money=10" goto (and here the level thing,so if in file is Level=10 it goes to level 10)
Is it possible ? If yes pls gimme code :D

Re: Saving progress/game

Posted: 04 Jan 2012 11:26
by Squashman

Code: Select all

 FOR /F "tokens=1,2 delims==" %%I in (Gamesettings.txt) DO IF "%%I"=="Level" GOTO Level%%J

Re: Saving progress/game

Posted: 04 Jan 2012 11:31
by silent
Hmm,when i write check (i will explain later,why check) it takes me back to level1 but in GameSettings.ini file (ive changed it from txt to ini) is

Code: Select all

level2

Full code of my testing batch file

Code: Select all

@echo off
:START
echo If you have been already playing,write 1 and you will be redirected to your level
echo If you want to play again write again

set /p saved=

if %saved% ==1 goto check
if %saved% ==again goto level1

:level1
echo Write 1
set /p task=

if %task% ==1 goto level2

:level2
echo level2 >GameSettings.ini
echo Write 2

set /p task=

if %task% ==1 goto level3

:level3
echo level3 >GameSettings.ini
echo Pause
pause

:WrongLevelSpecified
echo It seems something has benn done wrong
pause

:check
FOR /F "tokens=1,2 delims==" %%I in (Gamesettings.ini) DO IF "%%I"=="level" GOTO level%%J

:hehe
pause >nul


What happens ?

I have also used

Code: Select all

set /p var= <GameSettings.ini
if %var% ==level2 goto level2
if %var% ==level3 goto level3


But it was redirecting me to level 1 too :D

Oh,i forgot that i needed to write 1 to go to :check,but when i write 1,it goes to :hehe (its after the :check)

Re: Saving progress/game

Posted: 04 Jan 2012 12:27
by silent
K,i have done the saving myself,with code

Code: Select all

set /p var= <GameSettings.ini
goto :%var%

but i want to save the users name with the level, how ?