Saving and Loading
by Foestar · in Torque Game Engine Advanced · 12/13/2009 (3:53 am) · 9 replies
So I'm having trouble following a resource for saving and loading. The resource can be found HERE by Pat Wilson.
I did what I thought I was supposed to in order to get the resource working so I could better understand it. But it seems again I'm doing something wrong. I added the file to my project and put it within my solution before rebuilding. I got two errors after rebuilding and both are listed below.
EDIT: Hmm, am I using the url code in the forum wrong? O.o I did "url="http://www.torquepowered.com/community/resource/view/6636/"]HERE[/url" with start and open of course and it tries to go to "http://www.torquepowered.com/community/forums/viewthread/%22http://www.torquepowered.com/community/resource/view/6636/%22".
I did what I thought I was supposed to in order to get the resource working so I could better understand it. But it seems again I'm doing something wrong. I added the file to my project and put it within my solution before rebuilding. I got two errors after rebuilding and both are listed below.
Error 1 fatal error C1083: Cannot open include file: 'core/fileStream.h': No such file or directory FILE:c:TorqueTGEA_1_8_2ProjectsKingdom DefendersbuildFilesVisualStudio 2008projectsloadsaveobject.cpp LINE:6 Error 2 error BK1506 : cannot open file '....LinkVC2k8.Release.Win32Kingdom Defendersloadsaveobject.sbr': No such file or directory FILE:BSCMAKESo lets start there. Any info on how to properly use this resource would be much appreciated.
EDIT: Hmm, am I using the url code in the forum wrong? O.o I did "url="http://www.torquepowered.com/community/resource/view/6636/"]HERE[/url" with start and open of course and it tries to go to "http://www.torquepowered.com/community/forums/viewthread/%22http://www.torquepowered.com/community/resource/view/6636/%22".
About the author
Foestar Entertainment Biohazard Entertainment
#2
12/13/2009 (2:18 pm)
Ok, found where it was located and changed "core/filestream.h" to "core/stream/filestream.h" and now I get 4 errors. They involve read/write.Error 1 error C2039: 'Write' : is not a member of 'FileStream' Error 2 error C2065: 'Write' : undeclared identifier Error 3 error C2039: 'Read' : is not a member of 'FileStream' Error 4 error C2065: 'Read' : undeclared identifierSo read and write are not in filestream. I didn't see anything in the resource about having to add these in. O.o
#3
12/13/2009 (9:38 pm)
change both "Write" and "Read" to "write" and "read". functions are case sensitive
#4
12/13/2009 (11:06 pm)
Thanks for all the help so far. But I got another set of errors as I changed that. Now it came up with the following errors.Error 1 error C3867: 'Stream::write': function call missing argument list; use '&Stream::write' to create a pointer to member Error 2 error C3867: 'Stream::read': function call missing argument list; use '&Stream::read' to create a pointer to memberSo I changed it.
if( !fs.open( filename, FileStream::read ) ) //to if( !fs.open( filename, &FileStream::read ) )and now it comes up with the errors
Error 1 error C2664: 'FileStream::open' : cannot convert parameter 2 from 'overloaded-function' to 'Torque::FS::File::AccessMode' Error 2 error C2664: 'FileStream::open' : cannot convert parameter 2 from 'overloaded-function' to 'Torque::FS::File::AccessMode'
#5
12/13/2009 (11:18 pm)
Torque::FS::File::Write is what you are looking for, and Torque::FS::File::Read for the read function
#6
12/13/2009 (11:49 pm)
Yep, that did it. Thanks a bunch!
#7
Head = "Leather Cap" etc.
These are the things I intend to be saving so that the player can come back and find their character, their profile, and still have on their gear. And I wasn't sure if a text file would be all that great for reading and saving multiple lines of variables.
12/14/2009 (8:15 pm)
Quick question. What kinda of file do you recommend for saving small sets of data such as variables? I've seen the some people save to text files. But I'm not quite sure what kinda of file would fit my needs. I am simply going to make a variable to hold the number of profiles, characters, the characters name along with variables for each set of gear. Head = "Leather Cap" etc.
These are the things I intend to be saving so that the player can come back and find their character, their profile, and still have on their gear. And I wasn't sure if a text file would be all that great for reading and saving multiple lines of variables.
#8
12/14/2009 (8:45 pm)
a text file works perfectly for that. If you want to go the extra mile you can save your stats on an online server so your players can access them from anywhere!
#9
12/14/2009 (8:51 pm)
Okay thanks. I'll try out both methods.
Torque 3D Owner Scooby Brown
i think for tgea its in core/filesystem/filestream.h because between tge and tgea have some files in different places.