Hi All,
How can I access an object's member variable from a non-member function?
Within the game daemon script, I'm trying to access a member variable of the active object:
== my_object.script ==
...
var myState = "foo";
...
== game_daemon.script ==
...
var active_object = Game.GetActiveObject();
var active_object_state = active_object.myState;
Game.Msg(active_object_state); // this prints [null]
...
So far, the only way I can get this to work is by creating a GetMyState() method in my_object.script that returns myState and then calling active_object.GetMyState() from game_daemon.script.
Do I need to write a wrapper method for every variable I need to access from a non-member function? If so, is there a way to put the method in a script attached to the object (via this.AttachScript()), so that I don't need to copy the wrapper methods into every instance of the object? (In my testing, calling Game.Msg(this.myState) from the attached script also displays [null].)
Thanks,
Greg