Game Development Community

Any other traps ?

by YisionChan · in Torque 3D Beginner · 10/01/2014 (7:23 am) · 4 replies

I'M a newer ,and I find some traps in torque script .
For example,a[++i] is not work as we think in c++.
artguitest is a wrong path,instead of /.

Who can tell me more about this?Thanks!

#1
10/01/2014 (7:30 am)
art\\gui\\test is a wrong path form :(
#2
10/01/2014 (10:47 am)
Look at other scripts - follow their example.

Prefix increment/decrement operators don't work, only postfix.
++%i; // does nothing
%i++; // increments %i as in C++

// also note...
i; // this is not a "variable", it's a name - in Torquescript, it's like a global variable but may behave oddly.  Usually used for global object names.
%i; // this is a local variable
$i; // this is a global variable

// paths are expecting forward slashes
%path = "art\gui\test"; // nope
%path = "art/gui/test";

%relativePath = "./server/subFolder"; // path starts at folder where this script is executed.
%fullPath = "scripts/server/subfolder"; // path starts at base

// paths all base from the folder that the Torque exe is in.
// in Linux/Unix environments, paths are case-sensitive

http://www.garagegames.com/products/torque-3d/documentation - pick the Reference Guide in the left sidebar then read the Syntax Guide documents.

Torquescript is "C-like," not C++ implemented as a scripting language. The only trap is in your mind - you have to remember you're not writing C++ code, you're writing Torquescript.
#3
10/02/2014 (2:02 am)
Thank you very mush!😊😊
#4
10/02/2014 (8:29 am)
No problem! Happy to point new folks in the right direction.