Saving Binary files
by Bruno · in Torque Game Builder · 03/14/2006 (9:15 am) · 1 replies
Hi..,
Currently i'm saving all my data in text files, using T2D script functions, like this :
and loading it like this :
But this saves in standard .txt files.
Are there in commands in T2D that saves this kind of data, as a binary file ??
It exists in C, so i assume there must be something similar in T2D script ??
thanks,
Bruno
Currently i'm saving all my data in text files, using T2D script functions, like this :
%fr = new FileObject("FR");
%yes = FR.OpenForWrite("/savegame/file.bin");
if(%yes)
{
FR.writeline($Player_Name);
FR.writeline($Level_Name);
FR.writeline($Actual_Score);
FR.Close();
}and loading it like this :
%fr = new FileObject("FR");
%yes = FR.OpenForRead("/savegame/file.bin");
%n_lines = 0;
while ( !FR.isEOF() )
{
%line = FR.readline();
%n_lines++;
if(%n_lines == 1) $Player_Name= %line;
if(%n_lines == 2) $Level_Name = %line;
if(%n_lines == 3) $Score = %line;
}
FR.Close();But this saves in standard .txt files.
Are there in commands in T2D that saves this kind of data, as a binary file ??
It exists in C, so i assume there must be something similar in T2D script ??
thanks,
Bruno
About the author
Torque 3D Owner Luke D
Default Studio Name
What reason are you looking to use binary instead of ascii text in this case? Is it size, or obfuscation to prevent tampering? If it is the latter, you may want to search around for the encryption resources (especially this one) and use that instead.
Otherwise if you've got a specific need to output into a particular binary format, you're probably looking at a custom C engine modification, though it should be fairly easy to do.