• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

THE QUESTION - is it okay to use global timer for instant actions?

Level 9
Joined
May 24, 2016
Messages
304
I guess it might be a problem, that Im using global timer for some functions.

IDK. I guess that because of some strange bugs


So the thing is, I declared a global timer T for instant functions (for avoid declaring local timer every time)
you know, like that

JASS:
function GetCalledPaladinKnight takes nothing returns nothing
set T = GetExpiredTimer()
set I = GetHandleId(T)
set I2 = LoadInteger(Hash,I,0) //I

if GameOver != true then
call MsgP(GetPlayerId(Player(I2)), "The Paladin Knight is called to serve you." ,5.)

call TimerStart(T,6,false,function SpawnPaladinKnight)
else
//call echo("game is ended")
call FlushChildHashtable(Hash,I)
call DestroyTimer(T)
endif

endfunction
But you know, I'm not sure about it now.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
Should be fine as long as the function does not do any actions that could interrupt itself with another function using the same global.

The technically better approach is still to use local variables. I am guessing you want to do this to avoid the JASS virtual machine bug that requires nulling local declared local agent variables before the function returns?
 
Level 9
Joined
May 24, 2016
Messages
304
Should be fine as long as the function does not do any actions that could interrupt itself with another function using the same global.

The technically better approach is still to use local variables. I am guessing you want to do this to avoid the JASS virtual machine bug that requires nulling local declared local agent variables before the function returns?
I was using that way because it's just simple code optimization, instead of declaring loca timer every time I appeal to another timer function
But recently I found a rare bug that just works like my timer wont expire. At all. I have no idea what is that, so I probably decide to switch back to local timers. I hope that will prevent the bugs. If so, Ill text the results here.
 
Top