Today i tried to make a trigger for respawning units after some time, you know. Ofc i used a timer. And it didn't work. The entire damn day i've been trying to find a mistake in my trigger, without any result. I even created a new test map and copied an already working timer there - it didn't work. My friend did the same, with the same result. This looks extremely weird. Problem is: the timer just shows "0:00:00" from the beginning whatever time i set. So, has anyone else expierenced this?
Well, for me they also worked fine, until today. Would you be so kind to make a new map and create this simple trigger: Map init > Start timer, create timer window?
The reason why your timer does not work is the garbage collection algorythm used for the galaxy programming language.
If you create a timer in the local function scope, the timer will get destroyed once you exit the function (scope), and therefore the timer window cant access it any longer.
You can easily test that yourself by adding a 100 second wait at the end of your trigger - The timer will now "magically" work. The proper solution here is using a global variable for the timer to prevent the GC from destroying the timer.
0___________________________________________0
I only wonder why this question seems to have never been raised before (at least i've never seen this answer). And how my previous timers worked all the time long... I so much love Blizzard...
Ok, thank you guys.
Most of the time the garbage collection is no issue and doesnt even get noticed by the user. All objects which still have references on them within the executed code are not destoryed, however, this native function is an exception to the rule because it basically runs in its own thread but outside the .galaxy platform, which can cause this sort of weird issues.
Well it sounds like something i experienced a while ago!! If you create a global timer, make sure that when you create it it's set to (Last started timer) and not (New Timer).
ATTACHMENTS
Timer.png
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Today i tried to make a trigger for respawning units after some time, you know. Ofc i used a timer. And it didn't work. The entire damn day i've been trying to find a mistake in my trigger, without any result. I even created a new test map and copied an already working timer there - it didn't work. My friend did the same, with the same result. This looks extremely weird. Problem is: the timer just shows "0:00:00" from the beginning whatever time i set. So, has anyone else expierenced this?
Timers work fine for me, I've never used timer windows though. Perhaps post your triggers or map.
@Elmaex: Go
Well, for me they also worked fine, until today. Would you be so kind to make a new map and create this simple trigger: Map init > Start timer, create timer window?
This is what isn't working:
@FunBotan: Go
only if the timer is a local variable. use a global instead
@FunkyUserName: Go
I'm not using variables in the example at all. Should i?
The reason why your timer does not work is the garbage collection algorythm used for the galaxy programming language.
If you create a timer in the local function scope, the timer will get destroyed once you exit the function (scope), and therefore the timer window cant access it any longer.
You can easily test that yourself by adding a 100 second wait at the end of your trigger - The timer will now "magically" work. The proper solution here is using a global variable for the timer to prevent the GC from destroying the timer.
0___________________________________________0
I only wonder why this question seems to have never been raised before (at least i've never seen this answer). And how my previous timers worked all the time long... I so much love Blizzard...
Ok, thank you guys.
Most of the time the garbage collection is no issue and doesnt even get noticed by the user. All objects which still have references on them within the executed code are not destoryed, however, this native function is an exception to the rule because it basically runs in its own thread but outside the .galaxy platform, which can cause this sort of weird issues.
@FunBotan: Go
Well it sounds like something i experienced a while ago!! If you create a global timer, make sure that when you create it it's set to (Last started timer) and not (New Timer).