Save and Load .bat game
You could also save/load with only values, like
(
echo %highscore%
echo %playername%
echo %points%
) > savegame.sav
and load them with
< savegame.sav (
set /p highscore=
set /p playername=
set /p points=
)
The first part simply redirects the echo
outputs to a file.
The loading part using also file redirection, but in this case as input source.set /p
commands in a block can read consecutively lines from the file.
Try something like this:
@echo @ECHO OFF > savegame.cmd
@echo SET ITEMS=%ITEMS% >> savegame.cmd
@echo SET HEALTH=%HEALTH% >> savegame.cmd
@echo SET MONEY=%MONEY% >> savegame.cmd
will "save" those three variables in savegame.cmd
. Then you can call
that file to reload the variables.
(Doing it with a for /f
is quite a bit trickier.)