Game Development Community

How do I get a member' value from scripting

by Ken · in Torque Game Builder · 06/30/2005 (9:53 pm) · 2 replies

I define a structure XY in c++

struct XY
{
int x;
int y;
};
and I have been registered the XY type to scripting.

I define XY g_Var;g_Var.x =1;g_Var.y =2; then Con::addVariable("g_Var",TypeXY,&g_Var);

below in Scripting .cs

I use echo(g_Var) ,I can see g_Var's value(1 2) in console.log

but I use echo(g_Var.x) ,I don't See g_Var.x 's value.

how can I get single member x or y's Value?

thanks!

#1
07/01/2005 (12:12 am)
Sounds like you need to use:
echo ("g_Var.x=" SPC GetWord (g_Var, 0));
echo ("g_Var.y=" SPC GetWord (g_Var, 1));
#2
07/03/2005 (11:59 pm)
Philip Mansfield:

thank you very much!