Game Dev Tech Notes =
Tools, Tricks + Assets
Torque Script Notes
I discovered that for a programmer that is used to strongly typed languages (C++, Java, etc.) that Torque Script programming changes the paradigm somewhat.
It is best to work on very small pieces at a time. Then test them and even step through using something like Torsion. This is required since
you can make many mistakes which will not be caught during compilation. The following notes have been taken from my own commented cs code.
Things to look for when things don't make sense when programming in Torque Script. (maybe the first two just relate to me, but I'll share):
- Drinking water?
- Get enough sleep?
- Put the % in front of the variable (for locals) and the $ in front of variables (for globals).
You may make the mistake of putting these at the end of the variable, especially if you have been a Visual Basic programmer, you may be sorely tempted to put them after (ints and strings in earlier VB used % and $ respectively)
- For C/C++ programmers you need to remember that multiple dimensioned arrays are not myMatrix[m][n] but instead, myMatrix[m,n] (there are other formats to represent the same thing - but you will prefer this one.)
- Remember to add the keyword "function" in front of class::method's (unlike C++ or Java there is no return type) so,
think...
function MyClass::myMethod(%typeless_params, ...)
{
}
- Remember to exec() any new modules you write. Otherwise you may just keep wondering why the function is never called. Once again, unlike C++, the compiler will never complain. Also, order may be important to you in the usage of the exec() but please read below about onAdd() and onLevelLoaded() if this is the case.
- Use MyClass::onAdd(%this) and don't forget to access super class via Parent::onAdd(%this) where unlike other
object calls, the %this must be explicitly passed. Of course, the super class will need it's block of code as MySuperClass::onAdd(%this).
- Don't assume all objects that you may need access to are constructed (exist) during your particular usage
of OnAdd(). I you need access to other objects, remember the order of datablock and object construction (new'd)
and use onLevelLoaded(), where (at least in TGB 1.7.4) each object gets this message after the level is loaded and most init's have been called.
- ...
Progress on Park Planet Nine (PP9)
I finally was able to get a decent tunnel built as an
interior using Torque's Constructor, slice
and finally exported as a Torque dif.

I've annotated the problems I still need to solve.
- A "brush" has disappeared.
- A "leak" problem.
- Texture needs to map better. Smoothing would make the crease disappear.
Last updated: Sept 10, 2008