Accessing Globals in Behaviors
by Dustin Sims · in Torque Game Builder · 08/18/2007 (7:21 pm) · 3 replies
I am trying to put an object's ID number into a Global Array.
This is in an object's onupdate method inside a behavior.
However, when I check the $BallArray in my main scripts it is not changed.
I know the $Ballarray contains the ID while in the behavior by echoing it.
But if I echo it once back in another function in my main scripts it will contain nothing as if behavior script is not accessing the same global variable.
Everything worked and I used the same code in my other scripts but when I placed it in behavior it stopped working.
Any ideas on why this happens or is this just part of using behaviors...
Do I need to access the Global differently while inside a behavior?
This is in an object's onupdate method inside a behavior.
$BallArray[%xTempArrayPos,%yTempArrayPos] = %this.owner;
However, when I check the $BallArray in my main scripts it is not changed.
I know the $Ballarray contains the ID while in the behavior by echoing it.
But if I echo it once back in another function in my main scripts it will contain nothing as if behavior script is not accessing the same global variable.
Everything worked and I used the same code in my other scripts but when I placed it in behavior it stopped working.
Any ideas on why this happens or is this just part of using behaviors...
Do I need to access the Global differently while inside a behavior?
#2
I had a very long post decribing my problem in more detail and right after I posted.
I found where I was clearing the Array with a for loop in another script...
That's what happens when you write code a year ago and then
go back and try to change things..
Thanks for the post Spider, it kicked me into debugging mode...
Sorry for the wasted Forum space everyone.
08/21/2007 (8:16 pm)
**Edit: I had a very long post decribing my problem in more detail and right after I posted.
I found where I was clearing the Array with a for loop in another script...
That's what happens when you write code a year ago and then
go back and try to change things..
Thanks for the post Spider, it kicked me into debugging mode...
Sorry for the wasted Forum space everyone.
#3
08/22/2007 (1:41 pm)
Happens to the best of us...
Torque Owner Spider
More context (the whole function) would help me understand what was going on, too.