Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bsave and bload in rpgs

Status
Not open for further replies.

qbiscool

Programmer
Feb 18, 2004
33
CA
i need my help with a rpg im making. i need to no if there is a way to create a file in the users computer and then save every thing for the game in that folder everytime the user saves the game. i also need to no if there is a way to save a string instead of numbers. i have heard that the sadd function used with def seg and varseg works but i have tryed this multiple times and it did not work. i have one more question. would it be possible if when my program started it would instantly search for all files and list them by the names and stats for the users to choose from.
i think that this would make my rpg alot better.
 
>i need to no if there is a way to create a file in the users computer and then save every thing for the game in that folder everytime the user saves the game.
- Yes, it is. And what do you mean saying "every thing for the game "?

>i also need to no if there is a way to save a string instead of numbers.
- Yes. Actually it you PRINT #1,X
then X would be saved as string

>i have heard that the sadd function used with def seg and varseg works but i have tryed this multiple times and it did not work.
-No idea, I use simpler things (see above)

>i have one more question. would it be possible if when my program started it would instantly search for all files and list them by the names and stats for the users to choose from.
- There was a subroutine posted here that behaves much like "open file" dialog: lists files, allows select. I wasn't able to find it.
 
thanks for the help but i dont understand what you mean by <print #1,x> could you please explain it.by every thing for the game i mean stats, character names , and maybe, if im brave enough, upgrades for the game.
 
BSAVE and BLOAD are used for large blocks of RAM, usually large arrays.

Here is how you would save things like stats, names, et cetera.

First of all to create a folder for your game:
SHELL &quot;createdir c:\folder&quot;
You only need this command once, not in the game itself, this command should go in a setup program or something.

To save:
OPEN &quot;c:\folder\game.cfg&quot; FOR OUTPUT AS #1
PRINT #1, name$
PRINT #1, lives
PRINT #1, weapon
'and so on
CLOSE #1

To load:
OPEN &quot;c:\folder\game.cfg&quot; FOR INPUT AS #1
INPUT #1, name$
INPUT #1, lives
INPUT #1, weapon
'...
CLOSE #1
 
k i understand that but im not sure what you mean by setup.
i wouldnt no what to do to create a setup program but thanks for the information on the open command.
 
i tryed the open command and it says that the path is wrong. is there some way to do this with bsave and bload.
i read a tutorial and it said that if you use SADD instead of VARPTR it will save strings.

if any body nos how to list all of the saved game files for the user like i said at the top then please tell me
cus that would be realy usefull.
 
&quot;c:\folder&quot; is a hypothetical name, you have to direct it to a pre-existing folder, or you could just use &quot;c:\&quot;

A simple setup program would be something like:

INPUT ; &quot;What folder is your game currently in?&quot;, a$
SHELL &quot;createdir yourgame&quot;
SHELL &quot;copy&quot; + a$ + &quot;game.exe c:\yourgame\&quot;

It would create a folder for your game, and move the game to it.
 
&quot;c:\folder&quot; is a hypothetical name, you have to direct it to a pre-existing folder, or you could just use &quot;c:\&quot;

A simple setup program would be something like:

INPUT ; &quot;What folder is your game currently in?&quot;, a$
SHELL &quot;createdir c:\yourgame&quot;
SHELL &quot;copy&quot; + a$ + &quot;game.exe c:\yourgame\&quot;

It would create a folder for your game, and move the game to it.
 
open would be best to use. you can control what you want to input in it better. the syntax is...

open &quot;file.txt&quot; for input as #1

this will open a file for reading, and if there is no file by that name, it'll create that file. then, you can read/write to it using get/put.

put #1, hp
put #1, mp
put #1, strength

when you're finished, you close off the file.

close #1.

i'm a bit rusty with that command. if i made a mistake, feel free to correct me qbasicking!
 
i tryed bsave for creating a file for open. it looked like this:

//Start//
def seg = varseg(mystats)
bsave &quot;c:/rpg/mystat.dat&quot;, varptr(mystats), 10
def seg

open c:/rpg/mystats.dat&quot; for output as #1
print #1, maxhp
print #1, maxmp
print #1, level
....
close #1
//stop//

this works but it is realy slow. is there a better way of doing this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top