comparison LibKraken/LibKraken-1.0.lua @ 14:82170735e67c

- move co-routine handler to general lib - slightly better handling of pet actions
author Nenue
date Thu, 28 Jul 2016 23:58:53 -0400
parents a2fc77fa4c73
children
comparison
equal deleted inserted replaced
13:eeec4a600064 14:82170735e67c
235 addon.tab = KT.tab 235 addon.tab = KT.tab
236 addon.print = KT.print 236 addon.print = KT.print
237 end 237 end
238 end 238 end
239 239
240 return addon, (DEVIAN_WORKSPACE and function(...) _G.print(name, ...) end or function() end) 240 return addon, (DEVIAN_WORKSPACE and function(...) _G.print(name, ...) end or function() end), KT.wrap
241 end 241 end
242 242
243 243
244 244
245 local onEvent = function(self, event, arg1) 245 local onEvent = function(self, event, arg1)
358 end 358 end
359 SetButtonAnchor(button, self.UIPanels, self.UIPanelAnchor, self.UIPanelGrowth) 359 SetButtonAnchor(button, self.UIPanels, self.UIPanelAnchor, self.UIPanelGrowth)
360 return button 360 return button
361 end 361 end
362 362
363 --- Co-routine Handler kajigger
364 do
365 local tickerQueue = {}
366 local ticker
367 local instant = false
368 KT.tick = function()
369
370 if #tickerQueue == 0 then
371 ticker:Cancel()
372 ticker = nil
373 end
374 local func = tremove(tickerQueue, 1)
375 if func then
376 --print('#', #tickerQueue)
377 func()
378 end
379 end
380
381 KT.wrap = function(f)
382 if not ticker then
383 --print('create ticker')
384 ticker = C_Timer.NewTicker(.001, KT.tick)
385 end
386 tinsert(tickerQueue, f)
387
388 return #tickerQueue
389
390 end
391 end
363 392
364 KT.handler:RegisterEvent('ADDON_LOADED') 393 KT.handler:RegisterEvent('ADDON_LOADED')
365 KT.handler:RegisterEvent('PLAYER_LOGIN') 394 KT.handler:RegisterEvent('PLAYER_LOGIN')
366 KT.handler:SetScript('OnEvent', onEvent) 395 KT.handler:SetScript('OnEvent', onEvent)