XPerl and Class Portraits

XPerl and Class Portraits

by huggarn » Tue Mar 24, 2015 12:24 am

Hey everyone, I'm currently trying to accustome XPerl to my needs and wanted to do same thing I had in BC: Image

In TBC version it was as simple as chaning following function:
Code: Select all
function XPerl_Unit_UpdatePortrait(self)
   if (self.conf and self.conf.portrait) then
   local pf = self.portraitFrame
   SetPortraitTexture(pf.portrait, self.partyid)
      if (self.conf.portrait3D and UnitIsVisible(self.partyid)) then
         pf.portrait:Hide()
         pf.portrait3D:Show()
         XPerlSetPortrait3D(pf.portrait3D, self.partyid)
      else
      local classIcons = {
-- UpperLeftx, UpperLefty, LowerLeftx, LowerLefty, UpperRightx, UpperRighty, LowerRightx, LowerRighty
      ["WARRIOR"] = {0, 0, 0, 0.25, 0.25, 0, 0.25, 0.25},
      ["ROGUE"] = {0.5, 0, 0.5, 0.25, 0.75, 0, 0.75, 0.25},
      ["DRUID"] = {0.75, 0, 0.75, 0.25, 1, 0, 1, 0.25},
      ["WARLOCK"] = {0.75, 0.25, 0.75, 0.5, 1, 0.25, 1, 0.5},
      ["HUNTER"] = {0, 0.25, 0, 0.5, 0.25, 0.25, 0.25, 0.5},
      ["PRIEST"] = {0.5, 0.25, 0.5, 0.5, 0.75, 0.25, 0.75, 0.5},
      ["PALADIN"] = {0, 0.5, 0, 0.75, 0.25, 0.5, 0.25, 0.75},
      ["SHAMAN"] = {0.25, 0.25, 0.25, 0.5, 0.5, 0.25, 0.5, 0.5},
      ["MAGE"] = {0.25, 0, 0.25, 0.25, 0.5, 0, 0.5, 0.25}
      };

      local coords = classIcons[select(2,UnitClass(self.partyid))]
         if coords then
            pf.portrait:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
            pf.portrait:SetTexCoord(unpack(coords))
         else
         pf.portrait:SetTexCoord(0,1,0,1)
         end
      pf.portrait:Show()
      pf.portrait3D:Hide()
      end
   end
end


in Vanilla version however this function is not global addon wise but rather local defined separately in each module ( player, target, party ). Had no luck with changing these in-module functions, it kept giving me errors about not being able to init self: etc. Any clues?
huggarn
Tester
 

Re: XPerl and Class Portraits

by schaka » Tue Mar 24, 2015 7:15 am

Self doesn't exist in Lua 5.0 with the weird version WoW uses.
Instead you should try "this". Or alternatively stop using XPerl :P
schaka
Senior Sergeant
Senior Sergeant
 


Return to Addons & macros