Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Create the file to save/load data???

Author
Message
Jachan
16
Years of Service
User Offline
Joined: 1st Mar 2010
Location:
Posted: 12th May 2010 08:50
Would anybody tell me how to write the program that will save the data and load the data when come back (imagine of pokemon as start new-game option then save the data and then reset the game-system and do "Continue Game" to load the saved data)?
Of course, i already know about "WRITE STRING", "READ STRING", "OPEN TO WRITE", "OPEN TO READ"... but that is not what I mean to ask, exactly... what i really want to ask is that how can you save the data that have real-numbers WHEN the numbers are changing/changed (ex: ATK-5... when leveled up, ATK goes up to ATK-10)... I tried many different way but it does not seem that save-data like real-number... how can you do that as save the word-type AND number-type letters/numbers? thank you for anybody who is willing to help me!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 12th May 2010 10:29
Write float?
Read Float?

Just have a set format then make sure you import and export in the same order.

My signature is NOT a moderator plaything! Stop changing it!
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 12th May 2010 13:12
Pretty much you need to figure out everything you think you`ll need in your game but for example anyway :


I prefere Matrix1 plugin and this is writen in it.It`s good one, i recomend it to you.

Good luck with your game!

Where there is a will, there is a way.
I often edit my posts, that`s who i am
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th May 2010 16:00
Quote: "read float FileID,my_array(x)"

I put all of that hard work into making loading and saving of arrays almost seamless, and you still do it this way? ...

http://www.matrix1.demon.co.uk/Matrix1Utils_Help/Matrix1Util_29/save_array_to_datafile.html

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 15th May 2010 13:24
I`m learning how to drive on the highway, but i`ll remember this and use it in future.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th May 2010 16:23
I always wonder why people always seem to use open file to write etc, for stat saving or game saving. I prefer the nice and simple save array, load array commands. I have tended to use them since the original Dark Basic was released. It makes saving stats, levels, score etc easy as pie. I never have any issues with them either so to me is a simple and quick save option.



Basically you can save any info you need in the array and load it up on reload.

http://s6.bitefight.org/c.php?uid=103081
Jimpo
21
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 15th May 2010 20:32
Quote: "I always wonder why people always seem to use open file to write etc, for stat saving or game saving. I prefer the nice and simple save array, load array commands."

There are many advantages to using file commands over saving arrays for larger amounts of save data. With an array, you have to know everything possible thing you are going to save before you start in order to dimension the array correctly. This makes adding things a pain. But with reading from a file, you read line by line until you reach the end. It doesn't matter what order the data is in, or how much is in there.

It's also easier for the programmer to read. Instead of having to memorize array index 12 is the characters level stat, you just have to know what "Level99" means. Additionally, you can save different types of data in the same file, like text and integers. You can list what items are in a player's inventory right next to their level and HP.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 16th May 2010 23:36
You can save text and integers in an array, you just use a string array and then convert numbers using Str$(). I just find it easier setting up an array, labeling all the elements on setup for ref and using that. I tend to hate file parsing code so avoid whenever possible, only bother with that for name entry etc, and even then its from an array rather than using the open to read file command lol.
Horses for courses I suppose, but I am just used to doing things the easy way. Not much point loading up a separate file to load into my array, when I can just use the array..

http://s6.bitefight.org/c.php?uid=103081
Jachan
16
Years of Service
User Offline
Joined: 1st Mar 2010
Location:
Posted: 17th May 2010 18:54
ah i see... yeah, I already figured out about the "string" array because i only see the quote-marks there to be saved, not the integers.
If you believe it would works, Anakin (I like this better than "DVader", hope you don't mind? ), then i will try this code you just made and see it works for me. May the Force Help You.
Jachan
16
Years of Service
User Offline
Joined: 1st Mar 2010
Location:
Posted: 17th May 2010 19:10
okay, i just check it out... it didn't work. =(
Jachan
16
Years of Service
User Offline
Joined: 1st Mar 2010
Location:
Posted: 31st May 2010 23:40
bump?
if anybody think those codes are working, it is actually NOT... I tried it as those two posts right above, no good.
Anything else that might work better?

Login to post a reply

Server time is: 2026-07-25 23:12:10
Your offset time is: 2026-07-25 23:12:10