Saving settings/scores
BlitzMax Forums/BlitzMax Beginners Area/Saving settings/scores
| ||
Hello again, Ok I was wondering how hard it is to save/load data from a bmax games. Are there any spacific commands that I should learn to save and load game data? Also, I would like to save highscores, but I don't want the user to hack the the file and change them at will. I know this is alot to cover in one thread but I know that people around here have been helpful. |
| ||
Help -> Modules -> Filesystem & Help -> Modules -> Streams. |
| ||
In my game framework I used streams and wrote the names as byes, shifted to make them look weird, and also wrote the scores as integers so that you'd need to have a hex editor to alter them as they won't look like a string number you can edit in notepad. |
| ||
Hmmm this suff is a bit to advanced for me now, I guess i should learn more about blitz as a whole before i plunge into this stuff. Thank you sirs. |
| ||
Here's a simple example of saving 10 random scores in a way that can't be edited with notepad... just the scores though, not names (im a beginner too :P). There might be better ways, i dunno... check out the scores.dat file it creates in notepad.. |
| ||
THanks!! |
| ||
if it resides on the users PC, there is little way to "deny" access. you can look into encrypting the contents of the file before saving it. for now, judging by your previous posts, this may not be somthing you want to tackle right now |
| ||
You could use a SQLite database. You can name the database i.e. "file.dat" so that you do not see that this is database file by name. One more step would be scrambling the data when writing into database. I.e. write an a for 0, b for 1, and so on...(you get the idea :-) Last but not least you can save the whole database file in a password secured zip file. There are modules to read and write to zip files. Here is a nice tutorial about a hiscore list using SQLiter and a database. |
| ||
Sorry for reviving this thread but, I'm having a Hell of a time making a system to save and read scores. Would anyone be willing to write me a good set of functions that sort,save and read a highscore file? I usually don't like to ask for entire code sections and functions. Really if somebody could edit nyarla's code to save names that would be great. I tried to "RTFM" still confused a bit. |
| ||
Try thisStrict Local hiscore:Int[10] Print "===============" Print "Unsorted" For Local i:Int=0 To hiscore.length-1 hiscore[i]=Rnd(0,10000) Print "hiscore["+i+"]="+hiscore[i] Next hiscore.sort Print "===============" Print "Sorted" For Local i:Int=0 To hiscore.length-1 Print "hiscore["+i+"]="+hiscore[i] Next 'write hi-score Local out:TStream=WriteStream("c:\Hiscore.dat") For Local i:Int=0 To hiscore.length-1 WriteInt(Out,hiscore[i]) Next CloseStream(Out) 'Read hi-score Local In:TStream=ReadStream("c:\Hiscore.dat") For Local i:Int=0 To hiscore.length-1 hiscore[i]=ReadInt(In) Next CloseStream(In) Print "===============" Print "Read from File" For Local i:Int=0 To hiscore.length-1 Print "hiscore["+i+"]="+hiscore[i] Next |
| ||
That works well assari but how can i connect a string name to each score before adding it? |
| ||
I was afraid that you were going to ask that question. Same concept as above but instead of using an array, we use a type and a list as follows:- |
| ||
Thank you so much I'll credit you if you like. |
| ||
You'll welcomed. It's not necessary to credit me unless you want to. Good Luck with your program |
| ||
could you please explain me how could we store the images into several files and load it back to the screen all the images or a particular image from a file. |
| ||
You should really open your own topic rather than keep resurrecting other peoples year old posts *especially* when you don't seem to be asking a related question. Anyway, not sure what you mean by 'store the images into several files'. What images? If you mean screenshots then check savepixmappng |