View Single Post
09/07/14, 03:08 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
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:
  1. local function callAnotherSubFunction()
  2.      --do other stuff after zo_callLater is finished
  3. end
  4.  
  5. local function callFirstSubFunction()
  6.      --do stuff
  7.      zo_callLater(100, function()
  8.                --do something later
  9.                callAnotherSubFunction()
  10.           end)
  11. end
  12.  
  13. local function mainFunction()
  14.     callFirstSubFunction()
  15. 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:
  1. local function callFirstSubFunction()
  2.      --do stuff
  3.      zo_callLater(100, function()
  4.                --do something later
  5.                CALLBACK_MANAGER:FireCallback("zo_callLaterFinished")
  6.           end)
  7. end
  8.  
  9. local function callAnotherSubFunction()
  10.      --do other stuff after zo_callLater is finished
  11. end
  12.  
  13. local function mainFunction()
  14.     callFirstSubFunction()
  15. end
  16.  
  17. CALLBACK_MANAGER:RegisterCallback("zo_callLaterFinished", callAnotherSubFunction)
  Reply With Quote