Mercurial > wow > askmrrobot
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ec731d2fe6ba |
---|---|
1 local _, AskMrRobot = ... | |
2 | |
3 local waitTable = {}; | |
4 local waitFrame = nil; | |
5 | |
6 function AskMrRobot.wait(delay, func, ...) | |
7 if(type(delay)~="number" or type(func)~="function") then | |
8 print("Bad Arguments to amr__wait"); | |
9 return false; | |
10 end | |
11 if(waitFrame == nil) then | |
12 waitFrame = CreateFrame("Frame","WaitFrame", UIParent); | |
13 waitFrame:SetScript("OnUpdate",function (self,elapse) | |
14 local count = #waitTable; | |
15 local i = 1; | |
16 while(i<=count) do | |
17 local waitRecord = tremove(waitTable,i); | |
18 local d = tremove(waitRecord,1); | |
19 local f = tremove(waitRecord,1); | |
20 local p = tremove(waitRecord,1); | |
21 if(d>elapse) then | |
22 tinsert(waitTable,i,{d-elapse,f,p}); | |
23 i = i + 1; | |
24 else | |
25 count = count - 1; | |
26 f(unpack(p)); | |
27 end | |
28 end | |
29 end); | |
30 end | |
31 tinsert(waitTable,{delay,func,{...}}); | |
32 return true; | |
33 end |