Game Development Community

Namespace Troubles

by Eric Robinson · in Torque Game Builder · 04/17/2007 (8:33 pm) · 2 replies

I'm trying to dynamically set the namespace for an object in my game onLevelLoaded(). The issue is that any updates made appear to have no effect.

Are the namespace members "class" and "superClass" ONLY used on object creation? Is there anyway to modify the namespace hierarchy after object initialization?

#1
04/17/2007 (10:33 pm)
Namespaces are linked during the ::onAdd() (to simulation) calls, and cannot be changed after the object is registered with the simulation, so without re-writing the namespace code (and fully debugging your re-write), no, you cannot dynamically change the namespace of an object.

What you can do is to replace an object with a new object, and copy over the values, but have the new object be given the namespaces you need.
#2
04/17/2007 (11:05 pm)
@Stephen: Ahh, that's too bad... seeing that you can change them as you can any other variable (%obj.class and %obj.superClass), you'd almost expect them to update dynamically. Too bad there's no "const" in script, eh? ;D

I've started getting confused as to which fields will cause an immediate update upon set and which require the get/set member functions (I'm making heavy use of t2dTextObjects). Is this going to get generally standardized to one or the other? In 1.5 perhaps?

I figured out the new-object-&-copy method... it worked okay but was a bit out-of-the-way. Out of curiosity, how do you specify an object to copy without naming the new object explicitly? Does the following work?

%newObj = new t2dStaticSprite( : %oldObj)
{
     superClass = HurrayForNewSuperclass;
};

Heh, all of this makes a real good argument for installing this resource.