Save and load in batch RPG

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ragster66
Posts: 3
Joined: 05 Jan 2018 13:24

Save and load in batch RPG

#1 Post by ragster66 » 05 Jan 2018 13:42

Hi, I'm a newbie. I need to add a save and load section to my batch RPG. At certain
points in the game the player will get the option to save his progress before quitting.
Then at a later date Load the save back up and continue where he left off.

I have looked at a few "Lets make a batch RPG tutorials on you tube" but when I copy them into my game they don't work.

Any help greatly appreciated
Last edited by ragster66 on 05 Jan 2018 18:26, edited 1 time in total.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Save and load in batch RPG

#2 Post by Squashman » 05 Jan 2018 13:57

Sure would like to know where you got that code from.

Regardless of that, what do you want the SAVE file to look like.

ragster66
Posts: 3
Joined: 05 Jan 2018 13:24

Re: Save and load in batch RPG

#3 Post by ragster66 » 05 Jan 2018 16:41

The way it is shown in the post is not as i set it, I found it on You tube and the person doing the tutorial showed that it worked for him. It should be like this:

Code: Select all

@echo off
set HP=45
set DEX=20
set money=50
:home
echo Your HP is %HP% - Your Dexterity is %DEX% and you have %money% gold coins
pause
(
echo %HP%
echo %DEX%
echo %money%
)>save.sav
Then to show it worked he done this, first change the opening variables by any number then add the load program:

Code: Select all

@echo off
set HP=30
set DEX=10
set money=500
:home
echo Your HP is %HP% - Your Dexterity is %DEX% and you have %money% gold coins
(
set /p HP=
set /p DEX=
set /p money=
)<save.sav
goto home
he ran the first prog, then to demonstrate the save bit then altered the variable, added the load part and ran it, on screen it looked like


Your HP is 30- your Dexterity is 10 and you have 500 gold coins
press any key to continue
Then after the changes it reads
Your HP is 45- your dexterity is 20 and you have 50 gold coins
pause

It worked for him but not me. All I want is that the player at certain times gets the option to save his progress, exit and return another day Load and continue where he left off
cheers Raggy
Last edited by aGerman on 06 Jan 2018 05:50, edited 2 times in total.
Reason: code formatting

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Save and load in batch RPG

#4 Post by aGerman » 06 Jan 2018 05:53

2nd code

Code: Select all

@echo off &setlocal

(
  set /p HP=
  set /p DEX=
  set /p money=
)<save.sav

echo Your HP is %HP% - Your Dexterity is %DEX% and you have %money% gold coins
pause
Steffen

Osmium Programming
Posts: 14
Joined: 16 Oct 2017 20:15

Re: Save and load in batch RPG

#5 Post by Osmium Programming » 23 Jan 2018 00:53

Here's how I would load in your circumstance:

< filename.ext (
set /p var1 <--- Puts line 1 into a variable
set /p var2 <--- Puts line 2 into a variable, etc.
etc..
)

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Save and load in batch RPG

#6 Post by ShadowThief » 24 Jan 2018 16:41

Osmium Programming wrote:
23 Jan 2018 00:53
Here's how I would load in your circumstance:

< filename.ext (
set /p var1 <--- Puts line 1 into a variable
set /p var2 <--- Puts line 2 into a variable, etc.
etc..
)
You're going to want to put = signs after both of the variable names

Osmium Programming
Posts: 14
Joined: 16 Oct 2017 20:15

Re: Save and load in batch RPG

#7 Post by Osmium Programming » 24 Jan 2018 16:45

Wow, I completely blanked over that... I must have been way too tired to think

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Save and load in batch RPG

#8 Post by Squashman » 24 Jan 2018 17:03

Your answer is no different then Steffen's answer.

Osmium Programming
Posts: 14
Joined: 16 Oct 2017 20:15

Re: Save and load in batch RPG

#9 Post by Osmium Programming » 29 Jan 2018 18:55

Oh I just realized that the > thingy was the other way around.... :P

Post Reply