View Single Post
01-09-21, 01:44 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
You can just call button:SetAttribute() again when you need to update it. This can't be done during combat however.

For example:
Lua Code:
  1. local button=CreateFrame("Button",nil,aura_env.region,"SecureActionButtonTemplate");
  2. button:RegisterForClicks("LeftButtonUp","RightButtonUp");
  3. button:SetAllPoints(aura_env.region);
  4.  
  5. button:SetAttribute("*type1","target");
  6. button:SetAttribute("*type2","focus");
  7. button:SetAttribute("unit","none");--   Special UnitID for "no unit"
  8.  
  9. button:RegisterEvent("PLAYER_ROLES_ASSIGNED");
  10. button:RegisterEvent("GROUP_ROSTER_UPDATE");
  11. button:RegisterEvent("RAID_ROSTER_UPDATE");
  12. button:RegisterEvent("PLAYER_REGEN_ENABLED");
  13. button:SetScript("OnEvent",function(self)
  14.     if not InCombatLockdown() then--    Can't update in combat
  15.         local unit="none";
  16.         if IsInRaid() then
  17.             for i=1,MAX_RAID_MEMBERS do
  18.                 local raidunit="raid"..i;
  19.                 local raidid=UnitInRaid(raidunit);--    Unit-to-ID mappings aren't guaranteed
  20.                 if raidid and not UnitIsUnit(raidunit,"player") and (select(10,GetRaidRosterInfo(raidid))=="maintank" or UnitGroupRolesAssigned(raidunit)=="TANK") then
  21.                     unit=raidunit; break;
  22.                 end
  23.             end
  24.         end
  25.         self:SetAttribute("unit",unit);
  26.     end
  27. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-09-21 at 01:49 AM.
  Reply With Quote