TDN Highscore tutorial - save and load list
by Backman · in Torque Game Builder · 08/10/2008 (9:31 am) · 2 replies
I've done the advanced highscore tutorial that's on TDN, it stopped just short of explaining the load and save functions.
I don't quite get that part.. do I have to open a file object first and then somehow use the load and save functions..? Just typing in $highScoreList.save("~/data/highscorelist.dat") won't work, and I'm not exactly sure what to make of the function when I look at the code.
Also, depending on how this gets saved, is there a way to save it so that it doesn't actually let you open it in notepad and just replace the names and scores? Basicly, not save it as an ascii file?
Guessing loading the same would be good to get some help on. :)
Thanks a bunch for any help!
Link to tutorial:
http://tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Advanced/HighScores
I don't quite get that part.. do I have to open a file object first and then somehow use the load and save functions..? Just typing in $highScoreList.save("~/data/highscorelist.dat") won't work, and I'm not exactly sure what to make of the function when I look at the code.
Also, depending on how this gets saved, is there a way to save it so that it doesn't actually let you open it in notepad and just replace the names and scores? Basicly, not save it as an ascii file?
Guessing loading the same would be good to get some help on. :)
Thanks a bunch for any help!
Link to tutorial:
http://tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Advanced/HighScores
Associate James Ford
Sickhead Games
That resource uses a simSet and stores each score-entry as a simobject added to it. To load all you really have to do is exec the file just like any other torquescript file, and the saved objects will be re-created.
My guess is either it doesn't like the syntax of your path or it is saving it you just aren't looking in the right place.
Try this... $highScoreList.save( "highscorelist.dat" );
And look in your appdata folder for the saved file, not your project folder. For info on that...
tdn.garagegames.com/wiki/TGB/FileIO
You could save and then compile the files into dso if you want to prevent user modification. There is a "compile" console function just like exec.