2. How can I store data in a .txt file and then have Torque read it line-by-line?
%file = new fileObject();
%file.openForWrite("My/File/Path.txt");
%file.writeLine("Stuff here.");
%file.close();
%file.delete(); //Not deleting the file. Deleting the object that we were using to write in the file.
openForWrite will delete all the contents of the text file and then you can write whatever you want. openForAppend will just write whatever you want at the end of the text file.
3. How can I have Torquescript search for data in the .txt file?
%file = new fileObject();
%file.openForRead("My/File/Path.txt");
while(!%file.isEOF())
{
%line = %file.readLine();
}
%file.close();
%file.delete();
This will read the file line by line. There's no other way to read files in TorqueScript.
4. Do I even need a .txt file to store data that will appear again on a restart of Blockland?
Yes. You can do one of three things.
1. Use the above methods.
2. Use global variables and do export("$MyGlobal::Var"); (use * as a wild card) and then use exec(); to execute the file when you want to load the variables.
3. There is a default way that's method 2. Just make a global variable named $Pref::Whatever(client sided) or $Pref::Server::Whatever(server sided) and it'll automatically be stored and executed.
If you want to go with global variables then I suggest using method 2 if you're storing a lot of data.