-
Posted by predatorline on Tue, 23 Dec 2014 05:43:19
Hey Guys is it possible to delay an event? I have an addon which automatically "release the corpse" if the character has died :
local f = CreateFrame("Frame") f:RegisterEvent("PLAYER_DEAD") f:SetScript("OnEvent", function() RepopMe() end)
I tried it with the wait function from the wowwiki but it does nothing. Still instantly releases the corpse
local waitTable = {}; local waitFrame = nil; function still__wait(delay, func, ...) if(type(delay)~="number" or type(func)~="function") then 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 local f = CreateFrame("Frame") f:RegisterEvent("PLAYER_DEAD") f:SetScript("OnEvent", function() still__wait(2, RepopMe()) end)
Would appreciate if someone could tell me another method or if it not possible
-
Posted by jnwhiteh on Fri, 26 Dec 2014 10:39:28
Perhaps something like this? http://wowprogramming.com/snippets/Createamini-timerusingOnUpdate_3
-
Posted by minimulenz on Sun, 25 Jan 2015 04:19:22
You can use AceTimer to make timed operations: http://www.wowace.com/addons/ace3/pages/api/ace-timer-3-0/
A lot of addons use Ace because it's an unparalleled source of utility.