Thread Tools Display Modes
09/07/14, 03:08 PM   #1
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
09/11/14, 02:36 PM   #2
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Originally Posted by Seerah View Post
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.
I'd go with callbacks for this. Its more efficient.
  Reply With Quote
09/12/14, 12:38 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by Fyrakin View Post
I'd go with callbacks for this. Its more efficient.
Oops - yes. I forgot to put that this would be my preference.
  Reply With Quote
09/14/14, 07:19 AM   #4
Klingo
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 16
Thanks a lot for all the feedback, it's much appreciated!
The solution with callbacks definitely seems to be the best way to go on with.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Wait for a function to end before continue


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off