Game Development Community

Getting class name

by Tetraweb · in Torque Game Builder · 02/19/2007 (6:44 pm) · 3 replies

I must be missing something basic. In the editor, I assign an object to a class, and in the CLASSNAME::onLevelLoaded() everything works great, but if in that I put echo(%this.getClassName()); I get the parent class, usually t2dStaticSprite, not the class the object is in.

I came across this because in my onCollision routine I was trying to use
if (%dstObject.getClassName()$="someClass") {
and it didn't work.

First poster to point out the obvious mistake I must be making wins a beer.

Greg

#1
02/19/2007 (6:56 pm)
Assuming you have explicitly set the script class field of the object, you should just be able to use "%dstObject.class" if you want the script class name instead of the c++ class name.
#2
02/19/2007 (7:07 pm)
Thanks very much. I just put a beer in your fridge, behind the orange juice. It's on me.

Greg
#3
02/20/2007 (8:09 am)
TGB greatly re-defined the concept of "class" and "superclass" during it's beta stages, and getClassName() simply wasn't brought up to speed, since it's actually a left over from the original concept of "class" in Torque Core.

In TGB "class" and "superclass" are actually simply additional namespaces that are available, and have nothing to do with any c++ concept of "underlying c++ class that is used to implement the object", while getClassName does return the underlying c++ class that the object has as it's base when it is created.