Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hello.
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??

It should be entirely possible, although it could be some work.
The most straightforward way would be using something
simple like:ECHO %GAMESTATECODE% > SaveGame.txt
and then reading from that code to restore progress...
SET /p GAMESTATECODE= <SaveGame.txt
IF "%GAMESTATECODE%"=="ProgressLevel3" goto Level3I 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.

D:\batch>set $score=100 D:\batch>set $hitpoints=80 D:\batch>set $ $hitpoints=80 $score=100 D:\batch>set $>savegame.txt D:\batch>type savegame.txt $hitpoints=80 $score=100 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=100study 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

Thanks!
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.

is it possible to put them all in one document, rather than having a doc for every stat.
Yes. Adopt reno's "style."

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. EnteringSET $
...as 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
ranSET STAT_
...you 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 outputSET $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.~Mike

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |