This page documents a user-defined function that you can copy and paste into your addon. Replace <PREFIX> with your AddOn's prefix to avoid conflicts between different versions of these functions.
User defined functions < wait

Call this function to wait a specified amount of time before running another function with the given parameters. This function is useful when you rely on system messages to trigger your code as (especially with Guild related system messages) the system message is dispatched by the server sometimes before the results have been updated. Waiting to perform the next step of your code becomes easy with this function.

<PREFIX>_wait(delay, func [, param [,param [,...]]])

Function Parameters Edit

Arguments Edit

Number - the amount of time to wait (in seconds) before the provided function is triggered
Function - The function to run once the wait delay is over.
any - A list of any additional parameters (of any assorted type) to pass to the provided function when it is triggered.

Returns Edit

Boolean - true if it succeded in adding the wait to the wait table, If the first parameter is not a number, or the seconds parameter is not a function, any call to wait will automatically fail with a result of false.

NOTE: if the UIParent frame is being hidden, this wait will not work. It will never reach the end of the delay.

Example Edit



returns true after the initial call
after a 2.5 seconds delay, the string "Hello" will be displayed in the default chat frame.


local waitTable = {};
local waitFrame = nil;

function <PREFIX>__wait(delay, func, ...)
  if(type(delay)~="number" or type(func)~="function") then
    return false;
  if(waitFrame == nil) then
    waitFrame = CreateFrame("Frame","WaitFrame", UIParent);
    waitFrame:SetScript("onUpdate",function (self,elapse)
      local count = #waitTable;
      local i = 1;
      while(i<=count) do
        local waitRecord = tremove(waitTable,i);
        local d = tremove(waitRecord,1);
        local f = tremove(waitRecord,1);
        local p = tremove(waitRecord,1);
        if(d>elapse) then
          i = i + 1;
          count = count - 1;
  return true;

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.