0

I'm trying to make a .bat game and have most of the codeing already done. I looked up how to have the player save and load and it told me to save with this

@echo SET ITEMS=%ITEMS%   >> savegame.cmd

So it would save on savegame.cmd but how do i Load that information from savegame.cmd back to my .bat file?

2 Answers2

1

Also worth it to add a IF EXIST savegame.cmd ECHO "Do you want to overwrite a previous save?" ELSE @echo SET ITEMS=%ITEMS% > savegame.cmd

user4317867
  • 2,397
  • 4
  • 31
  • 57
0

The command you're using to save creates a .cmd file with the contents SET ITEMS=<items> where <items> is the current value of the ITEMS variable. To load this variable again, simply

call savegame.cmd

and the ITEMS variable will be set to the value stored in the samegame.cmd file.

Also, it's worth nothing that >> adds text to the end of the file while > writes a new file every time. If you think you're going to be saving a lot, it may be worth considering making the save command @echo SET ITEMS=%ITEMS% > savegame.cmd

SomethingDark
  • 13,229
  • 5
  • 50
  • 55