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 Discussion / Saving Tutorial???

Author
Message
Specters
19
Years of Service
User Offline
Joined: 30th Sep 2005
Location: idaho
Posted: 27th Oct 2005 00:18
Hi,
I was wondering on how to save files. I searched this up on the search form, but people just say to save it like a string. I know some about that but just wasn't sure on how to write the code for it. Say I move my character up a few times. Then I hit the save button, let say "S". So I hit "S" and the game saves. I close the game down and go to the load menu of the game. I load back to where my character was just positioned when I saved. Does anyone know what the code would be????
Thanks in advance...

Free Ipod
http://ipods.freepay.com/?r=24268699
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 27th Oct 2005 05:23
Drew G,

Save:


Let us say that the x,y and z positions of the character are 3,2,5.6. Then, the save file, when opened in a text editor, would look like:


Load:




+NanoBrain+
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 27th Oct 2005 19:55
Nanobrain,

I don't want to be a pain in the ass, but isn't:

and


much easier?

Immunity and Annihalation makes Immunihalation...
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 28th Oct 2005 02:42
Sven B,

Why yes, it is...ass. Just kidding...hehe. Thanks for the fixer.



+NanoBrain+
Specters
19
Years of Service
User Offline
Joined: 30th Sep 2005
Location: idaho
Posted: 28th Oct 2005 03:19
Lol, ummm, soon I suppose, I will write up a no media file that moves a cube on a matrix and prints the coordinates. I will leave the cube at a section, hit "S" to save, shut the game down and reopen it. I will try your help like that. Thanks though.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Oct 2005 11:16
Writing as floats has 2 features, one good, one not so good...

1. You can't open the file and read it, it's just garbage. (not so good)

2. If you want to protect your data a little, it's a good starting point.

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 28th Oct 2005 17:25
Quote: "1. You can't open the file and read it, it's just garbage. (not so good)"


What do you mean "you can't open the file and read it"? In all my test programs it works great!



It writes, reads... Anything you want.

Immunity and Annihalation makes Immunihalation...
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 28th Oct 2005 17:45
I think he meant opening them outside DB


http://dbfree.dbspot.com/ <- DB Freebie Archive! Royalty-free media for your games! FREE!
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 28th Oct 2005 17:48
I see,

Well, I don't see it as a bad thing... No offence, but why (beside testing the values did write properly), would you want to open them outside the game?

Immunity and Annihalation makes Immunihalation...
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 28th Oct 2005 17:53
Maybe editing? if you know how you're programming your game very well, you could be able to edit your position to test what happens if there's a wrong value in the save file, or something similar


http://dbfree.dbspot.com/ <- DB Freebie Archive! Royalty-free media for your games! FREE!
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 28th Oct 2005 17:58
I guess this can also be done in DB itself...

Immunity and Annihalation makes Immunihalation...
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Nov 2005 20:02
I think BatVink is referring to the write array commands rather than opening a file and writing the values in a loop.

In the past I too have had problems with the Write command and non-string variables so I switched my saving routines to convert everything to strings before writing, then converting the strings back to numeric variables on loading.

It's not ideal and involves another programming step I know, but after doing that, I never saw the problems I was having ever again.

And as DARKGuy says, if your programs don't load properly, with a text file you can open the data files in Notepad and check what data is in there.

TDK_Man

Login to post a reply

Server time is: 2025-05-22 12:59:58
Your offset time is: 2025-05-22 12:59:58