Get a number variable from a console object
by Bryce · in Torque Game Engine · 02/21/2009 (8:12 pm) · 2 replies
Hello everyone,
I've been fiddling with Gabriel Notman's pathfinding resource, trying to implement waypoint visibility weighting. I have a field (set through script) on each path node called visScore that tells the number of nodes that can see it.
I'm trying to incorporate this into the cost function. I would like to know how to take an integer (like 42) from a data field saved on a console object, and make it visible to the C++ code?
Help is appreciated!
I've been fiddling with Gabriel Notman's pathfinding resource, trying to implement waypoint visibility weighting. I have a field (set through script) on each path node called visScore that tells the number of nodes that can see it.
I'm trying to incorporate this into the cost function. I would like to know how to take an integer (like 42) from a data field saved on a console object, and make it visible to the C++ code?
Help is appreciated!
#2
11/23/2009 (3:52 am)
If anyone else is having trouble with this, you can also do this://Script:
%value = %myObject.value;
//Code:
F32 value = dAtof(myObject->getDataField(StringTable->insert("value"),NULL));At least, that's worked for me. A setDataField command also exists, but I haven't used it so I'm not sure about its usage. From the comments, something like this://Script:
%myObject.value = 10.0;
//Code:
F32 value = 10.0;
myObject->setDataField(StringTable->insert("value"),NULL,Con::getFloatArg(value));
Torque 3D Owner Thomas Bang
// TorqueScript $visScore = myPathNode.visScore; // C++ F32 visScore = Con::getFloatVariable("$visScore"); // TorqueScript->C++ // modify variable Con::setFloatVariable("$visScore", visScore); // C++->TorqueScript