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:
local ZO_CallLaterId = 1
function zo_callLater(func, ms)
local id = ZO_CallLaterId
local name = "CallLaterFunction"..id
ZO_CallLaterId = ZO_CallLaterId + 1
EVENT_MANAGER:RegisterForUpdate(name, ms,
function()
EVENT_MANAGER:UnregisterForUpdate(name)
func(id)
end)
return id
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.