Unable to instantiate an object.
by Mike Montalvo · in Torque Game Builder · 11/15/2006 (6:57 pm) · 10 replies
I have successfully built the TGB. I have a problem trying to instantiate a class called ChessBoard within the torque script. I have checked the log files and it is being compiled.
Here is the error:
Unable to instantiate non-conobject class ChessBoard.
Here is the error:
Unable to instantiate non-conobject class ChessBoard.
About the author
#2
11/16/2006 (5:11 am)
It is a c++ object. The class ChessBoard extends simObject. How do you declare it as a conobject?
#3
DECLARE_CONOBJECT(name);
IMPLEMENT_CONOBJECT(name);
Also you need to override some parent methods, like onAdd()
11/16/2006 (6:46 am)
Look into t2dSceneObject declaration&implementation. There is macro is used to declare console objectDECLARE_CONOBJECT(name);
IMPLEMENT_CONOBJECT(name);
Also you need to override some parent methods, like onAdd()
#4
error LNK2001: unresolved external symbol "public: virtual class AbstractClassRep * __thiscall ChessBoard::getClassRep(void)const " (?getClassRep@ChessBoard@@UBEPAVAbstractClassRep@@XZ)
What exactly does this mean?
11/16/2006 (6:43 pm)
Ok. i put the "DECLARE_CONOBJECT(ChessBoard)" in the header. Now I am getting the errorerror LNK2001: unresolved external symbol "public: virtual class AbstractClassRep * __thiscall ChessBoard::getClassRep(void)const " (?getClassRep@ChessBoard@@UBEPAVAbstractClassRep@@XZ)
What exactly does this mean?
#5
linker can't find body of the function.
11/16/2006 (11:24 pm)
I guess you forget IMPLEMENT_CONOBJECT(name);linker can't find body of the function.
#6
11/17/2006 (6:44 am)
Everything compiles now. Thanks. Is there something special you need to do in order to call certain methods in script that are defined within the C code?
#7
11/17/2006 (8:03 am)
Yeah, you have to declare those too. Look around in the source at some of the other engine functions exposed to script. They'll provide the best examples possible. For instance, grep the codebase for "t2dVectorAdd" (case insensitive and include the quotes in your search, they'll make things easier) and you'll find where they exposed that function to script.
#8
The only line I found was:
ConsoleFunction( t2dVectorAdd, const char*, 3, 3, "(t2dVector v1$, t2dVector v2$) - Returns v1+v2."){
I am not sure how this helps.
11/17/2006 (6:03 pm)
Do you mean in t2dVector.cc?The only line I found was:
ConsoleFunction( t2dVectorAdd, const char*, 3, 3, "(t2dVector v1$, t2dVector v2$) - Returns v1+v2."){
I am not sure how this helps.
#9
11/18/2006 (11:43 am)
That helps because it shows you the exact syntax you need to add the functions to the script interface. What you're looking at right there is how they added the t2dVectorAdd function to be accessible from script. You need to do the same thing. Replace t2dVectorAdd with the name of the function you want in script, and change all the other values to values that are appropriate for the script function you're building.
#10
11/18/2006 (6:13 pm)
Thanks for your help. I finally got it to run correctly.
Torque Owner Ben R Vesco