GetClassName() doesn't return specific name
by Yost Engineering · in Technical Issues · 10/24/2007 (2:44 pm) · 3 replies
Hello,
I have a datablock for a simple mesh, like so:
In script I want to be able to determine if and item is of this class - I tried using %obj.getClassName() but it always returns "StaticShape" rather than "Cow".
Any suggestions on how to return the specific class name?
Thanks in advance!
I have a datablock for a simple mesh, like so:
datablock StaticShapeData(AniCow)
{
category = "AnimatedObjects";
shapeFile = "~/data/shapes/Cow/Anicow.dts";
className = "Cow";
};In script I want to be able to determine if and item is of this class - I tried using %obj.getClassName() but it always returns "StaticShape" rather than "Cow".
Any suggestions on how to return the specific class name?
Thanks in advance!
#2
WheeledVehicle, Player, and in your case StaticShape. You could do something like:
then %obj.type would give you what you want.
10/25/2007 (8:10 am)
GetClassName() returns the class of the object:WheeledVehicle, Player, and in your case StaticShape. You could do something like:
datablock StaticShapeData(AniCow)
{
category = "AnimatedObjects";
shapeFile = "~/data/shapes/Cow/Anicow.dts";
type = "Cow";
};then %obj.type would give you what you want.
#3
%object.getClassNamespace();
At least this is how it seems to work under TGB 1.7.
-Unk
05/12/2009 (8:16 am)
For future reference, I think the proper method to get the class of an object as defined here or in the level builder is:%object.getClassNamespace();
At least this is how it seems to work under TGB 1.7.
-Unk
Torque 3D Owner Matthew Jessick
;)
To give data on the question, getClassName() is tightly tied into the C++ class heirarchy, by default. I'm not sure what happens if you try to override that. Might not be good (might change the "script namespace" for the object). I see that Item objects use a field called classname, and that it is a field of a very basic game class. (No real answers here, sorry.)
If you were to do a %obj.getDataBlock().getName() it would return "AniCow" which might be adequate for your needs. Warning: this only works on the server. Datablock names aren't normally sent to the clients.