Game Development Community

set & get classnamespace

by MJ-meo-dmt · in Torque 3D Beginner · 10/20/2014 (12:13 am) · 1 replies

Hi, now this maybe totally noob but I don't get it...

In the world editor you can set the [class:(TypeString)] property to something. Is that value the same as the [className] value you get inside a datablock? If not is there a way that I can set it inside a datablock?

Because I'm making use of this:
if (%obj.getClassNamespace() $= "Shard")
{
  //dosomething
}

If I set that class value in the world editor it works obviously, but having the same value in the datablock of that object under className doesn't..

The only other way that I could come up with is, to make some item spawner and then create the item via:
function ItemData::createItem(%data)
{
   %obj = new Item()
   {
      dataBlock = %data;
      static = true;
      rotate = true;
      shardEffect[0] = "UberNess";
   };
   return %obj;
}

And before i return that %obj, i have to do %obj.setClassNamespace("Shard");...

I just want to find out if there is any other alternative ways.
Thanks

About the author

Open minded; Independent Thinker / Analytical Thinker; A Dreamer; A friend.


#1
10/20/2014 (5:59 am)
If you set the "class" in the editor you associate it with that script-side class.

Then:
%thisThingClass = %obj.Class;
%thisThingClass = %obj.getClassName();

The only time you can set a class name in script is during object construction:
%theThing = new Item()
{
  datablock = DATABLOCK;
  class = "myClass";
};

If you try to change an object's class elsewhere you will get "can't change object namespace" errors.