View Single Post
03/17/23, 12:54 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,993
RegisterForEvent is used with the EVENT_* constants and that events fire automatically by the game at some defined trigger.
You register a callback fnction hat is executed as the event triggers by the game.

RegisterForUpdate is a kind of a repeated check every n milliseconds where a callback function that you define is called each time.
So this is done to repetivle do checks every n milliseconds, like an OnUpdate task during moving controls on the screen, or check every n milliseconds if you are grouped etc. (-> makes not sense as if you get grouped or leave group there are events that fire and you can react on them instead of constantly check every n milliseconds something that cannot change without those events having fired).

zo_callLater is using RegisterForUpdate and calls your callback function the delay later that you have defined.
In some circumstances it's okay to use it as some data will not be updated "instantly", but as events fire the data of the events should be fine and a zo_callLater should not be needed there (unless you check anything that is not related to the particular event).

Perfomance wise it's always bet to use events, and register event filters (if possible) as they will be called at C code, before the lua event even triggers. If the filter say "event is not needed for you" it's the best as no lua code of your callback function will be called at all! (e.g. in combat/buff events filter for unit tag "player" to only see ylur combat related stuff, and strip other group player's or enemy cobmat/buff stuff).

Last edited by Baertram : 03/17/23 at 12:58 PM.
  Reply With Quote