• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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

Status
Not open for further replies.
Level 10
Joined
May 24, 2016
Messages
339
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,285
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 10
Joined
May 24, 2016
Messages
339
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.
 
Status
Not open for further replies.
Top