Game Development Community

It's possible create object namespaces in scritp?

by Luis Anton Rebollo · in Torque Game Engine · 03/17/2005 (2:18 am) · 5 replies

It's possible create object namespaces in scritp similar form than datablocks?

thx and sorry for my english.

#1
03/17/2005 (5:45 am)
I'm not 100% sure I understand what you are looking for, but Torque Script has what is called ScriptObjects which I think is what you are looking for.

$blah = new ScriptObject(MyObject);
$blah.someField = 10;
MyObject.someOtherField = 5;
MyObject::onCallback(%this, %a, %b)
{
    %c = %a + %b;
   echo(%c);
}
#2
03/17/2005 (11:41 am)
Thx for the reply but i need a class o namespace for object that uses same functions.

customitem1,2,3,4 -> CustomItem -> Item ...

In torque documentation:

Objects are created in TorqueScript using the following syntax:

            // In TorqueScript
            %var = new [b]ObjectType[/b](Name : CopySource, arg0, ..., argn) 
            {...

...
[b]ObjectType[/b]- Is any class declared in the engine or in [b]script[/b] ...

How i can declare a class in script???

Any idea.
#3
03/17/2005 (12:36 pm)
Ok, thx John.

I learned i can declare class and superclass as field of SimObject declaration :)

It's possible declare as superclass Item o GameBase?
#4
03/17/2005 (12:52 pm)
Error: cannot change namespace parent linkage for Item from ShapeBase to ScriptObject.

I think it's impossible :(
#5
03/17/2005 (1:21 pm)
Hmm I just posted in your new thread before I saw your replies here. I'm starting to get a small idea of what you want. It seems to me you are trying to create your own subclass of ShapeBase but want to do it in Torque Script exclusivley. I'm not 100% sure that's doable, but i'd have to do a little digging first. TS does support at least some OOP basics, but i'm not sure it takes it this far. Generally what you would do is create your subclass of ShapeBase on the C++ side then simply create an instance of your new class in the script. But let me do some digging around and see if you can do this 100% in script.