Thread: Run secure code
View Single Post
07-12-16, 06:32 AM   #20
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Well, you can't call the GenerateUnitFrames during combat, the GenerateUnitFrames is used to replace the "refreshUnitChange" to "_onattributechanged", here is a simple version

Lua Code:
  1. local _Task = {}
  2.  
  3. grpHeader:SetScript("OnUpdate", function(self, elapsed)
  4.     if not InCombatLockdown() and #_Task > 0 then
  5.         for _, cnt in ipairs(_Task) do
  6.             GenerateUnitFrames(self, count)
  7.         end
  8.         wipe(_Task)
  9.     end
  10. end)
  11.  
  12. function grpHeader:UpdateUnitCount(count)
  13.     tinsert(_Task, count)
  14. end

If you don't create buttons based on the auto-generated unit buttons, the refreshUnitChange and _onattributechanged will do the same work, only the refreshUnitChange won't be fired when a unit is set to nil, so I replace it with a better one when out of combat.

Last edited by kurapica.igas : 07-12-16 at 06:35 AM.
  Reply With Quote