Returning console objects to C++
by DIAG · in Torque Game Engine · 08/18/2004 (2:05 am) · 3 replies
Hello,
I am just beginning to play around with console objects and objects in C++. I was just wondering, if I declare an c++ class as a console object, and the create an instance of this object in script, can i return a reference to that object to the engine so that i can use it in my c++ code via script?
Thanks
Damien
I am just beginning to play around with console objects and objects in C++. I was just wondering, if I declare an c++ class as a console object, and the create an instance of this object in script, can i return a reference to that object to the engine so that i can use it in my c++ code via script?
Thanks
Damien
#2
08/18/2004 (2:31 am)
Thanks for your prompt reply....but is it possible to do it the other way around...declare and instance of the object in scripts...and return it to the c++ code via console method?
#3
Thanks
damien
08/18/2004 (7:16 am)
K i figure this out, its just reverse of what you showed me here really...another question while im here... im trying to use the initPersistFields() in order to define a variable that i can access directly from the script language. the variable i wish to access is declared as a static float. When i try to access this varaible, torque crashes. can static variables be accessed from script? i tried this with a bool that was not static and it worked fine.Thanks
damien
Torque Owner Markus Nuebel
Say you are creating your object in C++
Then you return the object id from your ConsoleMethod :
ConsoleMethod( TestClass, getMyObj, S32, 2, 2, "( )" "Retrieve an object") { ... return pObj->getId(); }Now you are ready to use the object in your scripts.
--Markus