Game Development Community

Bug? "class" doesn't seem to work properly anymore?

by Magnus Blikstad · in Torque Game Builder · 04/06/2007 (3:05 am) · 2 replies

The following code (that worked fine in 1.1.3) doesn't seem to work anymore, a bug?

%parent.Weapon[%slot] = new t2dStaticSprite () 
{  
        config = "LaserWeapon";		
	scenegraph = %this.owner.scenegraph; 
};

new t2dSceneObjectDatablock (LaserWeapon) {   
   class = "LaserWeapon";
   imageMap = "shipImageMap";
   frame = 1;
};

function LaserWeapon::onAdd(%this)
{
   echo ("LaserWeapon::onAdd");
}

As soon as I add the class = "LaserWeapon" line I get the following errors:
Error, cannot unlink namespace parent linkage for LaserWeapon for t2dSceneObjectDatablock.
Error: cannot change namespace parent linkage for LaserWeapon from t2dSceneObjectDatablock to t2dStaticSprite.

I can recreate most of the code I used to do this way with behaviors, but sometimes that becomes mighty annoying and "hacky"...

#1
04/06/2007 (4:26 am)
Try this:
new t2dSceneObjectDatablock (LaserWeaponObject) {
   class = "LaserWeapon";   
   imageMap = "shipImageMap";   
   frame = 1;
};
I think its becuase you are naming the datablock the same as your class.
#2
04/06/2007 (4:29 am)
Aha! Thank you. Yep, that was indeed it! (it did work fine that way in 1.1.3 though, ah well. It works now at least, good enough for me).