Author Topic: [SOLVED] General TARDIS help topic  (Read 5812 times)

1. Access to the model in what way? Currently the vehicle I'm using is in a completely seperate mod
He means load it into a modelling program.

You need to have access to the original model file (.blend .obj etc.) because you can't edit the .dts exported file.

You need to have access to the original model file (.blend .obj etc.) because you can't edit the .dts exported file.
Unless you get Shaper. Which is 100% possible.

Never heard of that. Is it from GarageGames?

bump
how come people quit answering a topic's questions after so long?
« Last Edit: November 21, 2014, 11:57:54 PM by superdupercoolguy »

Because you keep modifying the topic, it's best to put it in a post instead of modifying the topic's OP every time.

How do I write & read to config files? [STILL NEED HELP. NOT SOLVED. SERIOUSLY IT'S NOT.]
&
How do I get the length of a table/array? [STILL NEED HELP. NOT SOLVED. SERIOUSLY IT'S NOT. I CAN'T EVEN DO ANYTHING UNTIL THIS IS SOLVED.]
This if for reading/writing to files.

As for arrays you can use a loop to check to see their size, or keep adding/subtracting to a global variable while you change the array size.

Because you keep modifying the topic, it's best to put it in a post instead of modifying the topic's OP every time.
This. We can't help you because we don't know you have another problem

Anyways, there's multiple ways to save files. If you want to save a list of global variables, you can export("$Name*","file/path.cs"); with * as a wildcald, and reload with exec("file/path.cs");
If you want to save an object, %obj.save("file/path.cs"); and then reload the same way with exec
Or you can do:
This if for reading/writing to files.
to write a file in any format you want

As for arrays, because of their shoddy implementation in Torquescript, there is no .Length method like other languages
You have two options: either keep track of the length of the array as you create it, or, if the array is indexed with contiguous integers, and no elements are blank, you can iterate through it until you find one with a blank value

If you absolutely need to know the length of a torquescript array, just store the length of it in a separate variable and adjust your code to use that.

okay, another question: How do I create a function out of a string and run it

okay, another question: How do I create a function out of a string and run it
%function = "echo";
%args = "hi";
call(%function,%args);

or

%string = "echo(\"hi\");";
eval(%string);

Use the former in place of the latter whenever possible.
Also keep in mind, if your string contains any user input, you need to filter it for special characters, or you create injection vulnerabilities

okay, another question: How do I create a function out of a string and run it

Why do you need to do this?


File objects for the mentally impaired. A fileObject is like any other object in torque, it inherits functions from a class. The functions you need to use are openForRead, openForWrite, openForAppend, readLine, writeLine, close, and isEOF. Eg:

new FileObject(fo); //Create the FileObject
fo.openForWrite("filename.ext"); //Open this to replace all lines in the text file with a single line
fo.WriteLine("Replace all text in file with this");
fo.close(); // Close file before opening again
fo.openForAppend("filename.ext"); //Open this to add a line the end of filename.ext
fo.writeLine("Add this line to the end of the file");
fo.close();
fo.openForRead("filename.ext");
while(!fo.isEOF()) //While we are not at the end of the file
{
%inLine = fo.readLine(); //Reads the line, puts it in local variable inLine
echo(%inline); //This should echo to the console :
// Replace all text in file with this
// Add this line to the end of the file
}


As seen above, openForAppend and openForWrite effect the functionality of writeLine.