• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

newbie, timers vs periodic ttime

Status
Not open for further replies.
Level 5
Joined
Sep 22, 2012
Messages
90
good day peepz,

I would like to know more about timers. I've also been studying jass then I've noticed that "azeroth grand prix" uses timers instead of every periodic time stuff. How does timers differ from periodic time event?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Periodic events are not precise; a 0.1 second periodic event isn't triggered exactly every 0.1 seconds

Timers are precise, and can be handled in more ways than a periodic trigger.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Create both triggers, one with a periodic event and another with a timer, each one with a 1 second duration.
Also create 2 Integer variables, one for the periodic and another for the timer.

Make each one display message "Periodic - PeriodicInteger+1" in case of the periodic, and "Timer - TimerInteger +1" in case of the timer.

After some time, you'll see that Periodic Integer goes over or under the Timer Integer, because it triggers faster or slower.

It has ben widely said around that timers are precise.
 
Level 7
Joined
Jan 28, 2012
Messages
266
JASS:
function sayHi takes nothing returns nothing
    call DisplayTextToPlayer(Player(0),0,0,"Hello World")
endfunction

//add this into the trigger init
call TimerStart(CreateTimer(),3,true,function sayHi)

The Reason we use timers instead of triggers is they are faster(a whole lot faster)
and they only need one handle, as opposed to the 3 that are required if you use a trigger to do it.
 
Status
Not open for further replies.
Top