Batch File Save Game

June 1, 2009 at 15:33:03
Specs: Windows Vista
i've had an idea for a RPG batch file, and i think it could work, except for one thing.

everytime you open the game, you'd have to start from scratch. would it be possible to save the game internally or externally??

See More: Batch File Save Game

Report •

June 1, 2009 at 18:03:10
It should be entirely possible, although it could be some work.

The most straightforward way would be using something
simple like:


and then reading from that code to restore progress...

IF "%GAMESTATECODE%"=="ProgressLevel3" goto Level3

I suppose you could have several files, or use some more
advanced parsing data, to capture multiple variables (score,
hitpoints, etc) for a more complete restore.

Report •

June 1, 2009 at 22:03:56
D:\batch>set $score=100

D:\batch>set $hitpoints=80

D:\batch>set $

D:\batch>set $>savegame.txt

D:\batch>type savegame.txt

D:\batch>set $hitpoints=&set $score=

D:\batch>set $
Environment variable $ not defined

D:\batch>for /f "tokens=*" %a in (savegame.txt) do set %a

D:\batch>set $hitpoints=80

D:\batch>set $score=100

study this, and you will get the idea
to save game currentstate: set $>savegame.txt
to load game state: for /f "tokens=*" %a in (savegame.txt) do set %a

Report •

June 2, 2009 at 10:20:02
to tell you the truth, i'm not understanding reno's answer, but I like the Mike's answer. It is more of 'my style'.

Obviously, there are going to be several stats. is it possible to put them all in one document, rather than having a doc for every stat.

Report •

Related Solutions

June 3, 2009 at 15:53:00
is it possible to put them all in one document, rather than having a doc for every stat.
Yes. Adopt reno's "style."

Report •

June 3, 2009 at 16:17:31
Reno is using the same basic moves I am, but with
significantly more sophistication.

Rather then using ECHO to send each stat value to a text file
individually, he is using the SET command combined with a
known value for the first letter of the variable. Entering

SET $ in his example will produce the value of every variable
that starts with a $. (Read "set /?" for more info on why this
works)To clarify, you could get the same results if you called
your variables STAT_HP, STAT_GOLD, STAT_MANA and

SET STAT_ would get a friendly list of every stat in one command.

By redirecting this output to a text file, as Reno has done,
you get all of your stats saved in one move.

Reading them back from this file involves a FOR loop...which
I'm still getting the hang of. However, the plaintext of his FOR
command is that for every line in "savegame.txt", run a SET
command with the value of that line. So if the first line is
$hitpoints=80, the command will output

SET $hitpoints=80

...and then repeat the process for every line.

I hope this helps explain what Reno was talking about; If you
can get it going it's a very good solution to your problem.


Report •

Ask Question