View Single Post
06/24/18, 05:00 PM   #6
SDPhantom
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 47
They both work. Registering the timer directly with EVENT_MANAGER directly is more efficient than calling zo_callLater(), but the later is easier to deal with.

This is literally what zo_callLater() does.
Lua Code:
  1. local ZO_CallLaterId = 1
  2. function zo_callLater(func, ms)
  3.     local id = ZO_CallLaterId
  4.     local name = "CallLaterFunction"..id
  5.     ZO_CallLaterId = ZO_CallLaterId + 1
  6.  
  7.     EVENT_MANAGER:RegisterForUpdate(name, ms,
  8.         function()
  9.             EVENT_MANAGER:UnregisterForUpdate(name)
  10.             func(id)
  11.         end)
  12.     return id
  13. end

On an added note, if you use EVENT_MANAGER:RegisterForUpdate() and don't unregister the function, it'll just keep calling at the interval you gave it. This is something zo_callLater() simply can't do without calling it more times.
  Reply With Quote