Game Development Community

Getting a console variable through C++

by Bryce · in Torque Game Engine · 01/24/2009 (1:06 pm) · 4 replies

Hello Everyone, C++ noob question :-)

I have a variable set in script that looks like this:
%npc.isFriendlyInLOS = true;

I'm trying to hook this directly into a console method I've made, a version of ShapeBase::setImageTrigger specifically for AI Players. I want to retrieve the value of isFriendlyInLOS that was saved on the object. Would it be some kind of getField() function? Help would be awesome!

#1
01/24/2009 (1:54 pm)
Bryce, I found a link in my bookmarks that should help.

"Interfacing with the Engine"
http://www.garagegames.com/docs/tge/general/ch05s03.php

Maybe you can figure out how to reach that on the new site.
#2
01/24/2009 (1:59 pm)
Meh, just 404 errors...
#3
01/24/2009 (2:16 pm)
If you have the object, you can do this:

StringTableEntry fieldName = StringTable->insert("isFriendlyInLOS");
const char *fieldValue = myObj->getDataField(fieldName, 0);

The function dAtob(fieldValue) will convert the string into a boolean:

const bool isFriendlyInLOS = dAtob(fieldValue);
#4
01/24/2009 (5:31 pm)
That works! I've finally learned what all those dAtob() and dAtof() functions mean...Thank you!