Mercurial > wow > askmrrobot
view wait.lua @ 7:437e54a8a483 release-1.2.12.0
Curse
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Tue, 20 May 2014 23:57:01 -0500 |
parents | 6ef021bd17b2 |
children | 880a7273759f |
line wrap: on
line source
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 --