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!
If I want to stop a timer and re-set the time on it, will pausing and starting the time be sufficient? or should I call removetimer(udg_var). or will call removetimer permanently delete the gui variable?
What MyPad said. And if you're working in GUI then you shouldn't be Removing timers (unless the timer was created locally through custom script). Also, the only time you need to Pause a timer is when you want to stop a Repeating timer. You can then Resume it normally OR Start it again if you want to restart it.
Lastly, there's no such thing as "deleting a variable". You're always deleting the object being tracked by the variable.
It makes more sense once you see the code behind these things.
For example let's say we create a timer variable called MyTimer in GUI. Here's what happens:
vJASS:
udg_MyTimer = CreateTimer()
You're actually creating two things at once. 1) The Timer variable which is what's called a pointer. It simply acts as a reference. 2) The actual Timer object which is created through the CreateTimer() function. This object is really what's important, it is what you Start/Pause/Resume and will contain all of the information/mechanics that a Timer needs. GUI handles this automatically for you, so you don't have to worry about Creating the timer object, it's done already.
In Jass, you need to manually create the timer objects yourself.
Here's an example of creating multiple local timers and timer objects in Jass:
vJASS:
local timer t1 = CreateTimer()
local timer t2 = CreateTimer()
local timer t3 = CreateTimer()
So we just created 3 local timers and given each one it's own timer object, however, none of these timer objects are doing anything yet. That's because we need to tell them what to do using the TimerStart() function:
vJASS:
local timer t1 = CreateTimer()
local timer t2 = CreateTimer()
local timer t3 = CreateTimer()
// There are the parameters you must fill out: TimerStart(whichTimer, timeout, periodic, callback)
call TimerStart(t1, 1.50, true, SomeFunctionThatRunsWhenTheTimerExpires)
So here we told t1 (the first timer we created) to Start it's timer object, and we set it as Repeating (true) and to run every 1.50 seconds. Whenever it expires it will run the SomeFunctionThatRunsWhenTheTimerExpires function (that was a mouthful). That's a function that you would create yourself. However, in GUI, it would be whatever Trigger uses the Event "Your Timer expires".
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.