Game Development Community

Accessing Variables

by Diego Castaneda · in Torque 3D Professional · 07/10/2009 (12:30 pm) · 4 replies

in my game, i want to acces to variables from an other program like Borland C++, and i have to write over them or take the value they already have. does Torque 3D have an index for his variables or something that can help me do this in my game?,like a direction on memory or something?

#1
07/10/2009 (1:57 pm)
Accessing other programs memory directly like that is unsafe, bug-prone not to say evil. Variables are never in the same place in memory across different re-compiles, specially if your program is compiled with optimizations (in which case the variable names are also gone). You're also likely to face major problems with multi-threading.

I believe there are better ways for communicating between two programs on the same machine. I got two torque applications to talk in the same machine using the TCPObject, but you could use a lower level socket or something.
#2
07/10/2009 (2:00 pm)
You can expose variables from C++ using Con::addVariable like so

Con::addVariable( "foobar", TypeBool, &myBoolVariable );

From there on, you can read and write this variable from within TorqueScript.

Be careful to use the correct console type (look in console/consoleTypes.h).

//Edit: parallel post, but just noticed that my post is nonsense as you obviously meant crossing process borders here. Listen to Manoel.
#3
07/13/2009 (11:47 pm)
You could also make use of the telnet interface to the console system (Torsion and other TorqueScript IDE's use this for debugging for example).
#4
07/18/2009 (2:50 pm)
thanks guys for the help, i solved it writing the value of the variable in a txt file from borland, and then reading the txt file from torque and asigning the value to the variable i wanted in this case the value that you send to the function yaw and pitch.

thanks for the help