I was scrolling through this page:
http://docs.garagegames.com/torque-3d/official/content/documentation/Scripting/Overview/Syntax.htmland I found some interesting things.
Instead of something like
if(%admin)
{
%powerful = "yes";
}
else
{
%powerful = "not at all";
}
Or even
switch(%admin)
{
case 1:
%powerful = "yes";
case 0:
%powerful = "nopenopenope";
}
I can just use
%powerful = %admin ? "yes" : "nope";
If admin is 1, powerful is "yes". If admin is 0, powerful is "no".
I did not know of this.
I also learned that % can be used to find the remainder of an division operation.
So like. 34 goes into 40 once, with a remainder of 6.
So echo(40 % 34); returns 6.
40 % 22 returns 18.
40 % 18 returns 4. Cause 18 goes into 40 2 times, with a remainder of 4.
Of equal interest, though I didn't learn it from that particular page, I learned that-
instead of using %a++; or %a = %a + 1; to increment %a by 1.
I can use %a += 1; or if i want to increment it by five I can use %a += 5;
Similarly I can use all of the normal operators to do stuff like this-
if %a = 6 then:
%a += 5; sets %a to 11
%a -= 2; sets %a to 4
%a /= 3; sets %a to 2
%a *= 2; sets %a to 12
%a %= 5; sets %a to 1
Interesting stuff. I hope it's useful to someone other than me.