Mercurial > wow > askmrrobot
diff wait.lua @ 0:ec731d2fe6ba
Version 1.2.12.0
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Tue, 20 May 2014 21:43:23 -0500 |
parents | |
children | 6ef021bd17b2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wait.lua Tue May 20 21:43:23 2014 -0500 @@ -0,0 +1,33 @@ +local _, AskMrRobot = ... + +local waitTable = {}; +local waitFrame = nil; + +function AskMrRobot.wait(delay, func, ...) + if(type(delay)~="number" or type(func)~="function") then + print("Bad Arguments to amr__wait"); + return false; + end + 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 + tinsert(waitTable,i,{d-elapse,f,p}); + i = i + 1; + else + count = count - 1; + f(unpack(p)); + end + end + end); + end + tinsert(waitTable,{delay,func,{...}}); + return true; +end