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 / loading and saving = txt files

Author
Message
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 26th Feb 2005 17:52 Edited at: 26th Feb 2005 17:57
in my game eachtime you get up a level i want it to save that sounds easy but when you exit the program you have lost it all . after some thinking is there any way darkbasic to cretae txt files add text in them save it and be able to load it. remebering this is game not a txt editor so basically not even open note pad or anything + i dont what the person to have type in what level cause they could cheet.

unless you know any orther way
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 26th Feb 2005 18:18
open a file(.txt) for writing and store all the positions, health, weapons etc. in there. Then when you load it use open file for reading and save the whole thing to an array and get out all the things you need.


Thanks to Animeblood for the Logo!
FakeBlood
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Alabama, United States
Posted: 26th Feb 2005 18:24
Could do something like this...


For Lots of data to save and not just a Level you'll probably want to use an array. Check out the SAVE ARRAY command. As far as people cheating you will have to figure out a way to encrypt the file or you could probably just save the file as something other than a txt file, like your own made up extension. Never tried that one so dunno if it would work.
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 26th Feb 2005 18:52 Edited at: 26th Feb 2005 18:54
thanks ill have a look into it.
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 26th Feb 2005 18:56 Edited at: 26th Feb 2005 18:57
so where it says WRITE STRING 1,str$(PlayerLevel) in between the brackets is that where the txt it will create in the txt file
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 26th Feb 2005 19:02 Edited at: 26th Feb 2005 19:06
sorry i was an idiot i just looked at it player level is a varible and its printing the varible which is 10. this code i greght it works really well

but how do i get it to read the txt file
FakeBlood
22
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Alabama, United States
Posted: 26th Feb 2005 19:18 Edited at: 26th Feb 2005 19:19

File 1 in the READ STRING command may be in use already, if so change it to 2 or better yet close the first file.
If you wanted to change the string to a normal number after that you could do something like
AlexI
20
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 26th Feb 2005 20:04
THANKS i made an example program and put it in the code base

Login to post a reply

Server time is: 2025-05-23 19:46:07
Your offset time is: 2025-05-23 19:46:07