C++: cant .getField() for certain fields. (ex: GuiFadInBitmapCtr
by Jason Swearingen · in Torque Game Builder · 09/02/2005 (11:29 pm) · 2 replies
I'm having a problem using .getField() (or .setField()) to access certain fields set via torqueScript.
Specifically, GuiFadeInBitmapCtrl uses the .done field.
it is set internal to the workings of the class.
if I perform the work via torquescript, i can get/set the field values no problem:
but when I try doing the .getField() (or setfield) via C++ for some reason the call to const AbstractClassRep::Field *fld = findField(slotName); from SimObject::getDataField never finds the field.
here is my code:
Again, everything in the c++ code (above) evaluates properly, the same as the torquescript code when parsed by CodeBlock::exec .. everything evaluetes the same EXCEPT the const AbstractClassRep::Field *fld = findField(slotName); call (in getDataField) which returns null.
What am I doing wrong? is this a bug?
FYI: it looks like .done is set by GuiFadeinBitmapCtrl's parrent, if that matters (it probably does)
-Jason
================ EDIT:
If there is a better way to access fields via C++ let me know. (the reason I have this function as a console method is so I can call it via torquescript, for ease of reproing this bug)
Specifically, GuiFadeInBitmapCtrl uses the .done field.
it is set internal to the workings of the class.
if I perform the work via torquescript, i can get/set the field values no problem:
new GuiFadeinBitmapCtrl(StartupGui) {
profile = "GuiInputCtrlProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
helpTag = "0";
bitmap = "./images/GarageGames";
wrap = "0";
fadeinTime = "125";
waitTime = "3000";
fadeoutTime = "125";
};
StartupGui.done="0";
$isDone = StartupGui.done;
echo($isDone);but when I try doing the .getField() (or setfield) via C++ for some reason the call to const AbstractClassRep::Field *fld = findField(slotName); from SimObject::getDataField never finds the field.
here is my code:
ConsoleMethod(SimObject, getField, const char *, 3, 4, "obj.getField(key) ==>> (char*)value")
{
const char *ret;
SimObject* curObject = Sim::findObject(object->getId());
if(argc==3)
{
char curFieldArray[]={0};
ret = curObject->getDataField(argv[2],curFieldArray);
}else{
ret = curObject->getDataField(argv[2],argv[3]);
}
return ret ? ret : "";
}I realize that the SimObject* curObject = Sim::findObject(object->getId()); line is redundant. I was trying to mimic the torqueScript parsing as close as possible. (troubleshooting this issue)Again, everything in the c++ code (above) evaluates properly, the same as the torquescript code when parsed by CodeBlock::exec .. everything evaluetes the same EXCEPT the const AbstractClassRep::Field *fld = findField(slotName); call (in getDataField) which returns null.
What am I doing wrong? is this a bug?
FYI: it looks like .done is set by GuiFadeinBitmapCtrl's parrent, if that matters (it probably does)
-Jason
================ EDIT:
If there is a better way to access fields via C++ let me know. (the reason I have this function as a console method is so I can call it via torquescript, for ease of reproing this bug)
#2
After the fact, now I know I should have got a hint by .GetField() taking a "StringTableEntry" instead of a "const char*"
good learning experience, though learned very hard and bitterly :)
thanks again Robert,
-Jason
09/05/2005 (1:24 am)
@Robert: Awesome! Thank you sooo much. This was causing me many many hours of frustration.After the fact, now I know I should have got a hint by .GetField() taking a "StringTableEntry" instead of a "const char*"
good learning experience, though learned very hard and bitterly :)
thanks again Robert,
-Jason
Torque 3D Owner Robert Blanchet Jr.