Game Development Community

Maybe I'm going nuts

by Phillip O'Shea · in Torque Game Builder · 09/29/2007 (12:22 am) · 3 replies

So, firstly, who knew you could do this?

%position = %this.getPosition();
echo (%position.x);
echo (%this.getPositionX()); //Same as above!

Oh, and, to the best of my knowledge, this works *properly* now:

%x = (%y > 0) ? 1 : 0;

Before if you multiplied %x by anything it would nut out.

Edit: Yes, yes, I am nuts, I figured out my bug, arrrrgh, loooooong night *sigh*

About the author

Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.


#1
10/04/2007 (8:03 pm)
Heheh. I've always wanted to be able to do the %var.x thing in Torque Script, so I added it to the interpreter a while ago. I actually wasn't aware it made it into a release. I wouldn't rely on it, because I'm not confident that it works in all cases (hence why it's not documented). It certainly does make the code a lot cleaner, though.

Really it's just a different way of doing the same thing as 'getWord.' It's not specific to vectors. So, getWord(%var, 0) would return the same thing as %var.x regardless of the contents of %var. %var.y and %var.z work for words 1 and 2 also. I think you can even do crazy things like "10 20".x to return 10, although I don't know why that would ever be useful.

It's supposed to work with operators also, so you can do %var.x += 10 to add 10 to the x component or even something more complex like %var.y = %var.x + 7. Again, I'm not sure if this always works.
#2
10/04/2007 (8:08 pm)
Nice, Adam !
#3
10/04/2007 (11:54 pm)
Its exciting when you find these little bits of awesome.