There are two even better ways to accomplish this that do not use any sort of a timer to poll to see if it's ready.
#1 - Have the script you assign to the zo_callLater call actually call the next function when it's finished.
Lua Code:
local function callAnotherSubFunction()
--do other stuff after zo_callLater is finished
end
local function callFirstSubFunction()
--do stuff
zo_callLater(100, function()
--do something later
callAnotherSubFunction()
end)
end
local function mainFunction()
callFirstSubFunction()
end
#2 - Use
callbacks. Register for a custom callback (a custom event) which is fired by the zo_callLater call, and have your callback handler be the second function.
Lua Code:
local function callFirstSubFunction()
--do stuff
zo_callLater(100, function()
--do something later
CALLBACK_MANAGER:FireCallback("zo_callLaterFinished")
end)
end
local function callAnotherSubFunction()
--do other stuff after zo_callLater is finished
end
local function mainFunction()
callFirstSubFunction()
end
CALLBACK_MANAGER:RegisterCallback("zo_callLaterFinished", callAnotherSubFunction)