Class declaration
by Christos Karapiperis · in Torque Game Builder · 09/04/2006 (2:50 am) · 9 replies
How can I declare a class in torqueScript in a similar way like the header files in c++?
Is datablocks the only way or is there something closer to c++?
Thanks
Is datablocks the only way or is there something closer to c++?
Thanks
#2
$cat = new Animal();
but I have to do this:
$cat = new ScriptObject()
{
class = Animal;
};
and then define the Animal functions. Is this right or there is another way?
Thanks a lot.
09/05/2006 (1:20 am)
Ok, I'm fine with that. But is it necessary all the custom classes I made to be ScriptObjects? I think that I cannot use a statement like this : $cat = new Animal();
but I have to do this:
$cat = new ScriptObject()
{
class = Animal;
};
and then define the Animal functions. Is this right or there is another way?
Thanks a lot.
#3
$cat = new Animal();
but I have to do this:
$cat = new ScriptObject()
{
class = Animal;
};
and then define the Animal functions. Is this right or there is another way?
Thanks a lot.
09/05/2006 (1:21 am)
Ok, I'm fine with that. But is it necessary all the custom classes I made to be ScriptObjects? I think that I cannot use a statement like this : $cat = new Animal();
but I have to do this:
$cat = new ScriptObject()
{
class = Animal;
};
and then define the Animal functions. Is this right or there is another way?
Thanks a lot.
#4
It is necessary to make custom classes from predefined console objects,
like ScriptObject, ScriptGroup, t2dStaticSprite, and so on. Look to the TGB
Reference. Most of all objects has 'class' field. (except SimSet, SimGroup, but
use ScriptSet & ScriptGroup instead)
09/05/2006 (1:31 am)
This is right. And this in only way to link a function to 'Animal' namespace.It is necessary to make custom classes from predefined console objects,
like ScriptObject, ScriptGroup, t2dStaticSprite, and so on. Look to the TGB
Reference. Most of all objects has 'class' field. (except SimSet, SimGroup, but
use ScriptSet & ScriptGroup instead)
#5
09/05/2006 (1:34 am)
Thanks a lot. Now I got it!!!!
#6
Otherwise I suppose my fancy object will have be a t2dSceneObject so that I can get collision and mounting and such working.
Richard N.
09/15/2006 (12:25 pm)
So there is no way to create a new class myself that inherits? I have asked the question in thread www.garagegames.com/mg/forums/result.thread.php?qt=50847 as well.Otherwise I suppose my fancy object will have be a t2dSceneObject so that I can get collision and mounting and such working.
Richard N.
#7
09/15/2006 (4:01 pm)
Yes, you can have the behavoir of inheritance. See my answer to the other thread.
#8
I would have expected something like
11/10/2006 (9:44 pm)
So... there's no "namespace" or similar? I would have expected something like
$cat=new Animal().
#9
11/12/2006 (1:21 am)
There are namespaces in TS. You can't "new" anything in TS.
Torque Owner Ben R Vesco