Passing an object from script to C
by Vern Jensen · in Torque Game Builder · 12/07/2007 (1:42 pm) · 2 replies
Okay, so when you operate on the object that called a method, it's easy to access it from C++. For instance,
But what if I want to pass a second object to the C++ function? How can I access that object from C++ in the same way? i.e.
The first line in that function is bogus... but I'm guessing there should be some code that would be similar to that that would convert an Object's ID into an actual object pointer usable from C++.... some sort of a "lookUpObject" function. I just don't know what its name would be.
Thanks again... this should be the last of my C++ questions for a while. ;-)
%value = %myObject.getVernValue();
ConsoleMethod(t2dSceneObject, getVernValue, const char*, 2, 2, "() Blah blah...\n")
{
return object->getDataField(StringTable->insert("vern"), NULL);
}But what if I want to pass a second object to the C++ function? How can I access that object from C++ in the same way? i.e.
%value = %myObject.getVernValue( %secondObject );
ConsoleMethod(t2dSceneObject, getVernValue, const char*, 3, 3, "() Blah blah...\n")
{
TorqueObject secondObject = doSomething( argv[2] );
return object->getDataField(StringTable->insert("vern"), NULL);
}The first line in that function is bogus... but I'm guessing there should be some code that would be similar to that that would convert an Object's ID into an actual object pointer usable from C++.... some sort of a "lookUpObject" function. I just don't know what its name would be.
Thanks again... this should be the last of my C++ questions for a while. ;-)
#2
12/07/2007 (10:41 pm)
Awesome, that looks like exactly what I'm looking for... will try it later tonight. Thanks a ton!
Associate Phillip O'Shea
Violent Tulip
ConsoleMethod(t2dSceneObject, getVernValue, const char*, 3, 3, "() Blah blah...\n") { t2dSceneObject* secondObject = dynamic_cast<t2dSceneObject*>(Sim::findObject(argv[2])); secondObject->doSomething(); return object->getDataField(StringTable->insert("vern"), NULL); }