Accessing non-global script variable from source
by Chris Jorgensen · in iTorque 2D · 01/16/2011 (5:13 am) · 3 replies
So here's what I'm trying to do. Let's say I make a sprite in script and give it the class "testClass". I'll name the sprite $testObject. So far so good. Now I make a custom property of it, say "$testObject.isCool = true;".
Now, how do I get at that "isCool" value in source? I can use Con::getVariable("$testObject"), for example, to get the object ID. But I can't do Con::getVariable("$testObject.isCool"). That doesn't work!
Obviously, I can point to sprites in source easily. And it's easy to manipulate its standard fields, like position, speed, etc... but I can't seem to figure out how to get at these "additional" fields that are declared / set in script.
Can anyone help?
Now, how do I get at that "isCool" value in source? I can use Con::getVariable("$testObject"), for example, to get the object ID. But I can't do Con::getVariable("$testObject.isCool"). That doesn't work!
Obviously, I can point to sprites in source easily. And it's easy to manipulate its standard fields, like position, speed, etc... but I can't seem to figure out how to get at these "additional" fields that are declared / set in script.
Can anyone help?
About the author
Owner of Cascadia Games LLC
Torque 3D Owner Aun Taraseina
edit **** Oh.. wait I think I miss understood the question. You could just use