forums

TNT Basic Forums > Programming Q&A
saving
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-22-2006 19:46

Posted by:
shadowgate

Find more posts by shadowgate

how do i tell the game to make a file and save all the varibles in it when they quit?

12-22-2006 20:38

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

here is a post that might be helpfull

http://www.tntbasic.com/community/forums/showthread.php?threadid=1092

12-23-2006 01:29

Posted by:
shadowgate

Find more posts by shadowgate

saving

thank you

12-23-2006 17:20

Posted by:
shadowgate

Find more posts by shadowgate

but i need to save it and have it load the data when they put in the name.

12-23-2006 19:03

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

what name?

well when to call it whouldn't matter - you could create a save and a load procedure and call them whenever you want

12-24-2006 20:15

Posted by:
shadowgate

Find more posts by shadowgate

well it is supposed to be a login. with a username only.

12-26-2006 18:04

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

well of course you decide about the system you want

probably you could want to keep a directory with player files in it, probably each file having the name of the player?

so when, the player enters his name you could try to open the file with the same name

other methods could also be good

[if you need more help please post the bits of code you have now, it will be easier to point out what to change]

12-27-2006 01:05

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

I think I get this...

When the 'user' logs in, try and load a file with that name (plus whatever extension you are using), you probably have a variable with the username in it, so copy this to a temporary string and add the extension, then throw it at file load... If it's there then load your variables, if not, set all variables to default values and go for it, you could also create a new 'user account' at this time...

When saving your values you just use the username as the file name. If you need a bit more security you could encrypt the string - adding a predefined value to the ascii value of each character in the string is common (if you just need to hide the name), or read the string backwards, or in a predefined order.

A "Continue where you left off..." function is not a complex thing, it's usually done with 'profiles' or 'accounts' which require a name. If this is what you are having problems with then hopefully these suggestions will help, if it's more than that, and you are having trouble with the load save side then we'll need a bit more info on what you are trying to achieve.
If it's a straight forward dump of everything important in the system then I suggest you only do this with global variables, especially if you put the load / save functionality in a procedure. As long as you save and load data in the same order you shouldn't have a problem, and using arrays makes things a lot easier as you can do it within a loop (or two...).

If you need more specific help then please do let us know, there's always someone about to answer questions (although I do stop for Christmas, not for me you understand... it's for the children... Did I sound a bit too much like Cliff Richard then?). MERRY CLIFFMAS!

Danny (nods)

12-27-2006 01:18

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Oh... and another thing...

Just looked back at the original post. Using the method mentioned above you might want to look at 'save points'. You mentioned saving things when the user quits, well TNT doesn't have this option (it's not event driven so gets no warning of a quit). There are two ways of doing this: You can save automatically at the end of a level (if this is an option), if it's not you could try saving at specified points in the game (preferable as it doesn't interrupt the action) or at regular intervals (which can be horrible if you have a lot of data as the game will pause for a bit every time you save). The other option is to give a 'Save' button on the GUI. If you can't use a button (for whatever reason) you could look for an "S" key press and check the status of the command key at this time. Command+S is the usual way of saving progress, so is the best option by far... If they quit without saving it's their loss...

Danny (nods)

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.