Game Development Community

Torque Script Question

by Vittorio Cellucci · in Torque Game Engine · 02/25/2007 (12:42 pm) · 3 replies

Hi,
can someone help me straighten out dataobjects, namespaces and objects? I come from a C++ background, with some Java and C#.

Why does this code not work?

enableWinConsole(true);

function CSuperMan::hi(%this)
{
echo("CS HI");
}


%so = new sss(CSuperMan)
{
count = 1;
};
so.hi();


echo("hi");

I'm expecting to see the output
CS HI
hi

But I get errors instead:
main.cs (0): Unable to instantiate non-conobject class sss.
main.cs (0): Unable to find object: 'so' attempting to call function 'hi'
hi
%


Any help would be super,

Thanks.

#1
02/25/2007 (12:53 pm)
There are a few things I can see:

1) You have no "sss" class defined. Use ScriptObject, as in:
%so = new ScriptObject(CSuperMan) { count = 1; };

2) You need to continue usnig "%" on the "so" variable, as in:
%so.hi();

I think that will cover your problems... if not, just re-post your results and I'll take a look.
#2
02/25/2007 (4:56 pm)
Hi Willian,

Thanks, That worked, however I have a question. Do all my objects have to be a ScriptObject?

Thanks,
Vittorio
#3
02/25/2007 (4:59 pm)
Actually William,

You can ignore my last question, I got it now. Thanks for your help.